[英]Updating NPM Requires New Version of NPM(deadlock) With engines Requirement in package.json
當在package.json
中使用.npmrc
文件要求npm
的嚴格版本時,它會在按預期運行npm ci
時出錯,但不允許更新npm
版本。
package.json
"engines": {
"npm": "8.7.0"
}
.npmrc
engine-strict=true
錯誤(預期)
$ 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"}
嘗試更新 npm 時出錯(意外)
$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"}
使用npm install npm@8.8.0
更新npm
版本時,會拋出相同的錯誤。 安裝新版本需要新版本,導致死鎖...
在沒有此死鎖的情況下,在 Node.js 項目中執行npm
版本的適當方法是什么?
為什么不通過刪除.npmrc
文件或
"engines": {
"npm": "8.7.0"
}
然后安裝你想要的 npm package 然后把你的改變帶回來。 您也可以使用nvm進行更好和向后的版本更改
最終發現npm
只能全局更新,因此使用npm install -g npm@8.8.0
,而不是npm install npm@8.8.0
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.