Skip to content

Add support for configuring npm version in Node devcontainers#1616

Draft
sireeshajonnalagadda wants to merge 5 commits intodevcontainers:mainfrom
sireeshajonnalagadda:npm-version
Draft

Add support for configuring npm version in Node devcontainers#1616
sireeshajonnalagadda wants to merge 5 commits intodevcontainers:mainfrom
sireeshajonnalagadda:npm-version

Conversation

@sireeshajonnalagadda
Copy link
Copy Markdown
Contributor

@sireeshajonnalagadda sireeshajonnalagadda commented Apr 7, 2026

Context:
When using the Node feature in devcontainers, npm is installed globally but always defaults to the bundled version. This often leads to noisy update prompts when running npm commands, and any manual updates are lost after rebuilding the container.

Problem:

Developers frequently need to pin a specific npm version globally.

Current workaround requires adding an onCreateCommand in devcontainer.json to run npm install -g npm@.

This is repetitive and not baked into the image.

Solution (Implemented in this PR):

Added support for specifying npmVersion alongside version in the Node feature configuration.

Example usage:

json
"ghcr.io/devcontainers/features/node:1": {
"version": "24",
"npmVersion": "11.11.1"
}
Ensures npm version is installed globally during container build, avoiding update prompts and rebuild inconsistencies.

Changes made:

  • Adds a new npmVersion option to the Node devcontainer feature so users can pin npm (or set it to latest / none) directly in devcontainer.json.

  • Updates the Node feature install script to install/upgrade npm globally during build, including skip logic (none), retries, proxy handling, and a compatibility fallback when the requested npm version doesn’t match the Node version.

  • Adds/updates tests and scenarios to cover installing a specific npm version, skipping npm updates, upgrading to latest, and an incompatible “latest npm + Node 16” case.

Outcome:
Developers can now configure both Node and npm versions directly in their devcontainer setup, improving reproducibility and reducing noise from npm update prompts.

@sireeshajonnalagadda sireeshajonnalagadda changed the title feat(node): add npm version selection and installation options Add support for configuring npm version in Node devcontainers Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant