Skip to content

Commit 83c6103

Browse files
authored
Add pnpm in Node (#450)
* Add pnpm in Node * pnpm from npm * Restore README.md * Update install.sh * Update tests
1 parent d84e46b commit 83c6103

File tree

7 files changed

+19
-3
lines changed

7 files changed

+19
-3
lines changed

src/node/devcontainer-feature.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"id": "node",
3-
"version": "1.1.5",
4-
"name": "Node.js (via nvm) and yarn",
3+
"version": "1.2.0",
4+
"name": "Node.js (via nvm), yarn and pnpm",
55
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/node",
6-
"description": "Installs Node.js, nvm, yarn, and needed dependencies.",
6+
"description": "Installs Node.js, nvm, yarn, pnpm, and needed dependencies.",
77
"options": {
88
"version": {
99
"type": "string",

src/node/install.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,17 @@ if [ ! -z "${ADDITIONAL_VERSIONS}" ]; then
183183
IFS=$OLDIFS
184184
fi
185185

186+
# Install pnpm
187+
if type pnpm > /dev/null 2>&1; then
188+
echo "pnpm already installed."
189+
else
190+
if type npm > /dev/null 2>&1; then
191+
npm install -g pnpm
192+
else
193+
echo "Skip installing pnpm because npm is missing"
194+
fi
195+
fi
196+
186197
# If enabled, verify "python3", "make", "gcc", "g++" commands are available so node-gyp works - https://github.com/nodejs/node-gyp
187198
if [ "${INSTALL_TOOLS_FOR_NODE_GYP}" = "true" ]; then
188199
echo "Verifying node-gyp OS requirements..."

test/node/install_additional_node.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ source dev-container-features-test-lib
77

88
# 'lts' is some version of node 18 for a while.
99
check "version_on_path" node -v | grep 18
10+
check "pnpm" pnpm -v
1011

1112
check "v18_installed" ls -1 /usr/local/share/nvm/versions/node | grep 18
1213
check "v14_installed" ls -1 /usr/local/share/nvm/versions/node | grep 14.19.3

test/node/install_node_16_on_bionic.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ source dev-container-features-test-lib
77

88
# Definition specific tests
99
check "version" bash -c "node --version | grep 16"
10+
check "pnpm" pnpm -v
1011
check "nvm" bash -c ". /usr/local/share/nvm/nvm.sh && nvm install 10"
1112

1213
# Report result

test/node/install_node_on_universal_image.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ set -e
66
source dev-container-features-test-lib
77

88
check "version_on_path" bash -c "node -v | grep 'v19.1.0'"
9+
check "pnpm" pnpm -v
910

1011
# Report result
1112
reportResults

test/node/non_root_user.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ source dev-container-features-test-lib
77

88
# Definition specific tests
99
check "version" node --version
10+
check "pnpm" pnpm -v
1011
check "nvm" bash -c ". /usr/local/share/nvm/nvm.sh && nvm install 10"
1112

1213
# Report result

test/node/test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ source dev-container-features-test-lib
77

88
# Definition specific tests
99
check "version" node --version
10+
check "pnpm" pnpm -v
1011
check "nvm" bash -c ". /usr/local/share/nvm/nvm.sh && nvm install 10"
1112

1213
# Report result

0 commit comments

Comments
 (0)