When requiring a strict version of npm in package.json with an .npmrc file it gives an error when running npm ci as expected, but does not allow the npm version to be updated.
package.json
"engines": {
"npm": "8.7.0"
}
.npmrc
engine-strict=true
error (expected)
$ npm ci
npm ERR! code EBADENGINE
npm ERR! engine Unsupported engine
npm ERR! engine Not compatible with your version of node/npm: [email protected]
npm ERR! notsup Not compatible with your version of node/npm: [email protected]
npm ERR! notsup Required: {"npm":"8.8.0"}
npm ERR! notsup Actual: {"npm":"8.7.0"}
error when attempting to update npm (unexpected)
$npm install [email protected]
npm ERR! code EBADENGINE
npm ERR! engine Unsupported engine
npm ERR! engine Not compatible with your version of node/npm: [email protected]
npm ERR! notsup Not compatible with your version of node/npm: [email protected]
npm ERR! notsup Required: {"npm":"8.8.0"}
npm ERR! notsup Actual: {"npm":"8.7.0"}
When updating the npm version with npm install [email protected] the same error is thrown. Installing the new versions requires the new version, resulting in a deadlock...
What would be the appropriate way of enforcing an npm version in an Node.js project without this deadlock?
Eventually it turned out
npmcould only be updated globally, thus usingnpm install -g [email protected], instead ofnpm install [email protected]