Skip to content

Commit 362dfda

Browse files
authored
[node] - Removal of default installation of yarn v1(classic) (#1550)
* [node] - Removal of default installation of yarm v1(classic) * Fixing issue when node version passed as none. * check yarn version as well. * Minor version change as per review comment.
1 parent 2d57b3c commit 362dfda

6 files changed

Lines changed: 34 additions & 16 deletions

File tree

src/node/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Installs Node.js, nvm, yarn, pnpm, and needed dependencies.
2020
| nvmInstallPath | The path where NVM will be installed. | string | /usr/local/share/nvm |
2121
| pnpmVersion | Select or enter the PNPM version to install | string | latest |
2222
| nvmVersion | Version of NVM to install. | string | latest |
23-
| installYarnUsingApt | On Debian and Ubuntu systems, you have the option to install Yarn globally via APT. If you choose not to use this option, Yarn will be set up using Corepack instead. This choice is specific to Debian and Ubuntu; for other Linux distributions, Yarn is always installed using Corepack, with a fallback to installation via NPM if an error occurs. | boolean | true |
23+
| installYarnUsingApt | On Debian and Ubuntu systems, you have the option to install Yarn globally via APT. If you choose not to use this option, Yarn will be set up using Corepack instead. This choice is specific to Debian and Ubuntu; for other Linux distributions, Yarn is always installed using Corepack, with a fallback to installation via NPM if an error occurs. | boolean | false |
2424

2525
## Customizations
2626

src/node/devcontainer-feature.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "node",
3-
"version": "1.6.4",
3+
"version": "1.7.0",
44
"name": "Node.js (via nvm), yarn and pnpm.",
55
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/node",
66
"description": "Installs Node.js, nvm, yarn, pnpm, and needed dependencies.",
@@ -52,7 +52,7 @@
5252
},
5353
"installYarnUsingApt": {
5454
"type": "boolean",
55-
"default": true,
55+
"default": false,
5656
"description": "On Debian and Ubuntu systems, you have the option to install Yarn globally via APT. If you choose not to use this option, Yarn will be set up using Corepack instead. This choice is specific to Debian and Ubuntu; for other Linux distributions, Yarn is always installed using Corepack, with a fallback to installation via NPM if an error occurs."
5757
}
5858
},

src/node/install.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export PNPM_VERSION="${PNPMVERSION:-"latest"}"
1212
export NVM_VERSION="${NVMVERSION:-"latest"}"
1313
export NVM_DIR="${NVMINSTALLPATH:-"/usr/local/share/nvm"}"
1414
INSTALL_TOOLS_FOR_NODE_GYP="${NODEGYPDEPENDENCIES:-true}"
15-
export INSTALL_YARN_USING_APT="${INSTALLYARNUSINGAPT:-true}" # only concerns Debian-based systems
15+
export INSTALL_YARN_USING_APT="${INSTALLYARNUSINGAPT:-false}" # only concerns Debian-based systems
1616

1717
# Comma-separated list of node versions to be installed (with nvm)
1818
# alongside NODE_VERSION, but not set as default.
@@ -362,7 +362,9 @@ else
362362
fi
363363

364364
# Possibly install yarn (puts yarn in per-Node install on RHEL, uses system yarn on Debian)
365-
install_yarn
365+
if [ -n "${NODE_VERSION}" ] && [ "${NODE_VERSION}" != "none" ]; then
366+
install_yarn
367+
fi
366368

367369
# Additional node versions to be installed but not be set as
368370
# default we can assume the nvm is the group owner of the nvm

test/node/install_node_debian_bookworm.sh

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,24 @@ set -e
55
# Optional: Import test library
66
source dev-container-features-test-lib
77

8+
# Definition specific tests
9+
YARN_VERSION="4.9.4"
10+
811
# Definition specific tests
912
check "version" node --version
1013
check "pnpm" pnpm -v
11-
check "nvm" bash -c ". /usr/local/share/nvm/nvm.sh && nvm install 10"
1214
check "yarn" yarn --version
1315

16+
# Corepack provides shims for package managers like yarn. The first time yarn is invoked via the "yarn"
17+
# command, corepack will interactively request permission to download the yarn binary. To
18+
# avoid this interactive mode and download the binary automatically, we explicitly call "corepack use yarn"
19+
# instead (doesn't require user input). Once that command completes, "yarn" can be used in a non-interactive mode.
20+
check "yarn shim location" bash -c ". /usr/local/share/nvm/nvm.sh && type yarn &> /dev/null"
21+
check "download yarn" bash -c ". /usr/local/share/nvm/nvm.sh && corepack use yarn@${YARN_VERSION}"
22+
check "yarn version" bash -c ". /usr/local/share/nvm/nvm.sh && yarn --version | grep ${YARN_VERSION}"
23+
24+
check "nvm" bash -c ". /usr/local/share/nvm/nvm.sh && nvm install 10"
25+
1426
# Report result
1527
reportResults
1628

17-

test/node/install_node_debian_trixie.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,25 @@ set -e
55
# Optional: Import test library
66
source dev-container-features-test-lib
77

8+
# Definition specific tests
9+
YARN_VERSION="4.9.4"
10+
811
# Definition specific tests
912
check "version" node --version
1013
check "pnpm" pnpm -v
11-
check "nvm" bash -c ". /usr/local/share/nvm/nvm.sh && nvm install 10"
1214
check "yarn" yarn --version
1315

16+
# Corepack provides shims for package managers like yarn. The first time yarn is invoked via the "yarn"
17+
# command, corepack will interactively request permission to download the yarn binary. To
18+
# avoid this interactive mode and download the binary automatically, we explicitly call "corepack use yarn"
19+
# instead (doesn't require user input). Once that command completes, "yarn" can be used in a non-interactive mode.
20+
21+
check "yarn shim location" bash -c ". /usr/local/share/nvm/nvm.sh && type yarn &> /dev/null"
22+
check "download yarn" bash -c ". /usr/local/share/nvm/nvm.sh && corepack use yarn@${YARN_VERSION}"
23+
check "yarn version" bash -c ". /usr/local/share/nvm/nvm.sh && yarn --version | grep ${YARN_VERSION}"
24+
25+
check "nvm" bash -c ". /usr/local/share/nvm/nvm.sh && nvm install 10"
26+
1427
# Report result
1528
reportResults
1629

test/node/scenarios.json

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,5 @@
207207
"version": "lts"
208208
}
209209
}
210-
},
211-
"debian_yarn_from_corepack": {
212-
"image": "debian:11",
213-
"features": {
214-
"node": {
215-
"installYarnUsingApt": false
216-
}
217-
}
218210
}
219211
}

0 commit comments

Comments
 (0)