Skip to content

Conversation

@MaxBlack-dev
Copy link
Contributor

Description

This PR documents npm's behavior of prioritizing package versions based on the engines field when installing packages by name without a specific version.

Changes

  • Added a note to npm install [<@scope>/]<name> section explaining that npm prioritizes versions compatible with the current Node.js version
  • Clarified that if latest tag points to an incompatible version, npm installs the newest compatible version instead
  • Documented the workaround: explicitly specify @latest to install a specific version regardless of engines compatibility

Context

This behavior was introduced in npm 10.8.2 but was not documented, causing confusion for users who expected npm install <package> to always install the version tagged as latest. Users reported unexpected behavior where older versions were installed when the latest version had engines requirements that didn't match their Node.js version.

Closes #7704

@MaxBlack-dev MaxBlack-dev requested a review from a team as a code owner November 30, 2025 01:55
@owlstronaut owlstronaut merged commit 4864dd4 into npm:latest Dec 1, 2025
8 checks passed
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.

[DOCS] npm doesn't install the latest tagged version if engines are invalid

2 participants