1

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: psw-portal@1.0.0
npm ERR! notsup Not compatible with your version of node/npm: psw-portal@1.0.0
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 npm@8.8.0
npm ERR! code EBADENGINE
npm ERR! engine Unsupported engine
npm ERR! engine Not compatible with your version of node/npm: psw-portal@1.0.0
npm ERR! notsup Not compatible with your version of node/npm: psw-portal@1.0.0
npm ERR! notsup Required: {"npm":"8.8.0"}
npm ERR! notsup Actual:   {"npm":"8.7.0"}

When updating the npm version with npm install npm@8.8.0 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?

Mark wijkhuizen
  • 373
  • 3
  • 10

2 Answers2

1

Eventually it turned out npm could only be updated globally, thus using npm install -g npm@8.8.0, instead of npm install npm@8.8.0

Mark wijkhuizen
  • 373
  • 3
  • 10
0

Why don't you just remove deadlock by removing .npmrc file or

"engines": {
    "npm": "8.7.0"
}

then install your desired npm package then bring your changes back. also you can use nvm for better and also backward version changes

Ali Shefaee
  • 327
  • 3
  • 12