Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/node/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "node",
"version": "1.6.4",
"version": "1.6.5",
Comment thread
Kaniska244 marked this conversation as resolved.
Outdated
"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.",
Expand Down Expand Up @@ -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."
}
},
Expand Down
6 changes: 4 additions & 2 deletions src/node/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
15 changes: 13 additions & 2 deletions test/node/install_node_debian_bookworm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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


15 changes: 14 additions & 1 deletion test/node/install_node_debian_trixie.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 0 additions & 8 deletions test/node/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,5 @@
"version": "lts"
}
}
},
"debian_yarn_from_corepack": {
"image": "debian:11",
"features": {
"node": {
"installYarnUsingApt": false
}
}
}
}