-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[BUG] npm's strict engine check is confusing (when doing npm install npm
)
#6778
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
You're right there's no "install the latest compatible npm" logic; the only place in the ecosystem that captures that rn is nvm's |
npm install npm
)
Relatedly (I think): While on
Thankfully it still works well enough to downgrade to v9, but I'm concerned about what might happen in future versions! |
@ehoogeveen-medweb major version changes aren’t prevented by semver rules, it’s that usually package.json has ^ - but there’s no global package.json, so all updates , including breaking changes, are in-range. I wouldn’t suggest using either command with -g, since there’s no package.json for them. Instead, explicitly update your global deps (for which there should be very few) one at a time. |
@ljharb The documentation for npm update disagrees:
In this case |
Based on description this issue appears to be fixed from [email protected] Now using node v18.20.4 (npm v10.8.3)
~/workarea/rep/test-engine $ npm outdated -g
Package Current Wanted Latest Location Depended by
corepack 0.28.0 0.32.0 0.32.0 node_modules/corepack global
npm 10.8.3 10.9.2 10.9.2 node_modules/npm global
~/workarea/rep/test-engine $ npm install -g npm@latest
npm error code EBADENGINE
npm error engine Unsupported engine
npm error engine Not compatible with your version of node/npm: [email protected]
npm error notsup Not compatible with your version of node/npm: [email protected]
npm error notsup Required: {"node":"^20.17.0 || >=22.9.0"}
npm error notsup Actual: {"npm":"10.8.3","node":"v18.20.4"}
npm error A complete log of this run can be found in: /Users/milaninfy/.npm/_logs/2025-03-12T02_05_46_851Z-debug-0.log |
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
npm install --global npm
does a strict engine check with some confusing options:The check is not strictly enforced for non-global installation.
The check is not strictly enforced for
npm update --global npm
.The error message shown is generic and there's no indication that the check is due to installing
npm
in particular.The check is enforced by the installing
npm
, not by the install scripts of the version being installed. So the check is not applied when upgrading from npm@6 or when using another package manager such asyarn
orpnpm
. After installing, the warnings just taunt you that you made a bad decision and don't tell you how to restorenpm
to a working state.There is no obvious way to do the right thing when upgrading npm, namely installing the newest version compatible with the current node engine.
npm install --global npm
always resolves tonpm@latest
.See npm/template-oss#350 (comment)
Expected Behavior
No response
Steps To Reproduce
Environment
; copy and paste output from `npm config ls` here
The text was updated successfully, but these errors were encountered: