为什么`npm update -g`没有将我的全局包更新到最新版本?

时间:2017-07-13 07:39:38

标签: npm

我正在执行updating global packages的步骤,所以我执行了npm outdated -g --depth=0并得到了:

Package     Current  Wanted  Latest  Location
typescript    2.2.2   2.2.2   2.4.1

然后,我执行了npm update -g,但我仍然从npm outdated -g --depth=0得到了相同的输出。

执行npm list -g --depth=0也确认打字稿包尚未更新为2.4.1:

+-- bower@1.8.0
+-- gulp@3.9.1
+-- typescript@2.2.2
`-- typings@2.1.1

我错过了什么?

4 个答案:

答案 0 :(得分:9)

您必须使用this script或者一个接一个地使用它们。

这次全球更新是一个众所周知的突破点。 Here is the reference to this issue. They seem to have closed it without addressing the issue

答案 1 :(得分:5)

您还可以安装特定版本:

npm install -g typescript@2.4.1

答案 2 :(得分:2)

到目前为止,还没有一个简单的命令可以做到这一点。

您可以使用以下步骤来查找过时的软件包,并一步一步地对其进行更新。

  1. 确定哪些全局软件包需要更新:要查看哪些全局软件包需要更新,请在命令行上运行:

    npm outdated -g --depth=0
    
  2. 更新单个全局程序包:要更新单个全局程序包,请在命令行上运行:

    npm update -g <package_name>
    

答案 3 :(得分:0)

要在单个命令中自动将所有全局包更新到“最新”版本:

npx npm-check --global --update-all

这会将所有全局包更新到“最新”版本More information is available about npm-check,包括执行交互式更新、排除软件包等的能力。


相反,npm update -g 仅将全局包更新为 npm outdated --global 所示的“Wanted”版本,因为全局安装的包被视为使用指定的插入符号 semver 范围安装。


最后,如果您碰巧想将软件包更新(安装)到“最新”或“想要”之外的版本:

npm install --global <pkg>@<version>