簡體   English   中英

npm 更新不安裝最新的軟件包版本?

[英]Npm update dont install the last package version?

當我安裝

npm i nodemon

我當然總是得到最后一個版本,在這種情況下是:2.0.2,

但是如果我安裝一些舊版本,例如 npm i nodemon@1.18.11 之后我嘗試 npm update 我得到 1.19.4 版本但不是最后一個 2.0.2

就像我使用 npm install nodemon 一樣。

為什么 npm update 在這種情況下沒有更新到 2.0.2 ?

這取決於npm的版本,但如果npm update破壞了一個或多個依賴項,則不會獲得更新的主要版本的包。 事實上,您一直停留在 1.x 版上。 您可以輕松地使用npm i foo來獲取最新版本而不是警告。 有關更多詳細信息,請參閱https://docs.npmjs.com/cli-commands/update.html ,具體取決於您使用的npm版本(以及如何獲取以前的行為)。

這取決於 nodemon 的 package.json 條目。

例如,如果模塊具有以下依賴項:

{
  "dist-tags": { "latest": "1.2.2" },
  "versions": [
    "1.2.2",
    "1.2.1",
    "1.2.0",
    "1.1.2",
    "1.1.1",
    "1.0.0",
    "0.4.1",
    "0.4.0",
    "0.2.0"
  ]
}

並且您在 package.json 文件中指定了 '^':

"dependencies": {
  "module": "^1.1.1"  //npm update will install module@1.2.2, because 1.2.2 is latest and 1.2.2 satisfies ^1.1.1
}

或者,如果您的版本是使用“~”指定的,則如下:

"dependencies": {
  "module": "~1.1.1" // npm update will install dep1@1.1.2. Even though the latest tag points to 1.2.2, this version does not satisfy ~1.1.1, which is equivalent to >=1.1.1 <1.2.0. So the highest-sorting version that satisfies ~1.1.1 is used, which is 1.1.2
}

如需更多了解,您可以遵循此文檔: https : //docs.npmjs.com/cli-commands/update.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM