diff --git a/src/node/README.md b/src/node/README.md index 328af529f..2c6f8cba6 100644 --- a/src/node/README.md +++ b/src/node/README.md @@ -20,7 +20,7 @@ Installs Node.js, nvm, yarn, pnpm, and needed dependencies. | nvmInstallPath | The path where NVM will be installed. | string | /usr/local/share/nvm | | pnpmVersion | Select or enter the PNPM version to install | string | latest | | nvmVersion | Version of NVM to install. | string | latest | -| 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 | +| 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 | ## Customizations diff --git a/src/node/devcontainer-feature.json b/src/node/devcontainer-feature.json index 923afd2c2..ce792e43d 100644 --- a/src/node/devcontainer-feature.json +++ b/src/node/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "node", - "version": "1.6.4", + "version": "1.7.0", "name": "Node.js (via nvm), yarn and pnpm.", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/node", "description": "Installs Node.js, nvm, yarn, pnpm, and needed dependencies.", @@ -52,7 +52,7 @@ }, "installYarnUsingApt": { "type": "boolean", - "default": true, + "default": false, "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." } }, diff --git a/src/node/install.sh b/src/node/install.sh index 71d91ffe2..81696d59b 100755 --- a/src/node/install.sh +++ b/src/node/install.sh @@ -12,7 +12,7 @@ export PNPM_VERSION="${PNPMVERSION:-"latest"}" export NVM_VERSION="${NVMVERSION:-"latest"}" export NVM_DIR="${NVMINSTALLPATH:-"/usr/local/share/nvm"}" INSTALL_TOOLS_FOR_NODE_GYP="${NODEGYPDEPENDENCIES:-true}" -export INSTALL_YARN_USING_APT="${INSTALLYARNUSINGAPT:-true}" # only concerns Debian-based systems +export INSTALL_YARN_USING_APT="${INSTALLYARNUSINGAPT:-false}" # only concerns Debian-based systems # Comma-separated list of node versions to be installed (with nvm) # alongside NODE_VERSION, but not set as default. @@ -362,7 +362,9 @@ else fi # Possibly install yarn (puts yarn in per-Node install on RHEL, uses system yarn on Debian) -install_yarn +if [ -n "${NODE_VERSION}" ] && [ "${NODE_VERSION}" != "none" ]; then + install_yarn +fi # Additional node versions to be installed but not be set as # default we can assume the nvm is the group owner of the nvm diff --git a/test/node/install_node_debian_bookworm.sh b/test/node/install_node_debian_bookworm.sh index 53b29fcaa..8fb7230f5 100644 --- a/test/node/install_node_debian_bookworm.sh +++ b/test/node/install_node_debian_bookworm.sh @@ -5,13 +5,24 @@ set -e # Optional: Import test library source dev-container-features-test-lib +# Definition specific tests +YARN_VERSION="4.9.4" + # Definition specific tests check "version" node --version check "pnpm" pnpm -v -check "nvm" bash -c ". /usr/local/share/nvm/nvm.sh && nvm install 10" check "yarn" yarn --version +# Corepack provides shims for package managers like yarn. The first time yarn is invoked via the "yarn" +# command, corepack will interactively request permission to download the yarn binary. To +# avoid this interactive mode and download the binary automatically, we explicitly call "corepack use yarn" +# instead (doesn't require user input). Once that command completes, "yarn" can be used in a non-interactive mode. +check "yarn shim location" bash -c ". /usr/local/share/nvm/nvm.sh && type yarn &> /dev/null" +check "download yarn" bash -c ". /usr/local/share/nvm/nvm.sh && corepack use yarn@${YARN_VERSION}" +check "yarn version" bash -c ". /usr/local/share/nvm/nvm.sh && yarn --version | grep ${YARN_VERSION}" + +check "nvm" bash -c ". /usr/local/share/nvm/nvm.sh && nvm install 10" + # Report result reportResults - diff --git a/test/node/install_node_debian_trixie.sh b/test/node/install_node_debian_trixie.sh index 53b29fcaa..7f92b561d 100644 --- a/test/node/install_node_debian_trixie.sh +++ b/test/node/install_node_debian_trixie.sh @@ -5,12 +5,25 @@ set -e # Optional: Import test library source dev-container-features-test-lib +# Definition specific tests +YARN_VERSION="4.9.4" + # Definition specific tests check "version" node --version check "pnpm" pnpm -v -check "nvm" bash -c ". /usr/local/share/nvm/nvm.sh && nvm install 10" check "yarn" yarn --version +# Corepack provides shims for package managers like yarn. The first time yarn is invoked via the "yarn" +# command, corepack will interactively request permission to download the yarn binary. To +# avoid this interactive mode and download the binary automatically, we explicitly call "corepack use yarn" +# instead (doesn't require user input). Once that command completes, "yarn" can be used in a non-interactive mode. + +check "yarn shim location" bash -c ". /usr/local/share/nvm/nvm.sh && type yarn &> /dev/null" +check "download yarn" bash -c ". /usr/local/share/nvm/nvm.sh && corepack use yarn@${YARN_VERSION}" +check "yarn version" bash -c ". /usr/local/share/nvm/nvm.sh && yarn --version | grep ${YARN_VERSION}" + +check "nvm" bash -c ". /usr/local/share/nvm/nvm.sh && nvm install 10" + # Report result reportResults diff --git a/test/node/scenarios.json b/test/node/scenarios.json index d4c5dcb50..e3b4297a1 100644 --- a/test/node/scenarios.json +++ b/test/node/scenarios.json @@ -207,13 +207,5 @@ "version": "lts" } } - }, - "debian_yarn_from_corepack": { - "image": "debian:11", - "features": { - "node": { - "installYarnUsingApt": false - } - } } }