怎么把Npm和NodeJS更新到最新版本?

谷若汐

2018-10-29

我刚刚安装了Node.js和npm(用于其他模块)。

如何将Node.js和我正在使用的模块更新到最新版本?

可以用npm直接这样做,还是我必须删除并重新安装Node.js和npm才能获得下一个版本?

第91篇《怎么把Npm和NodeJS更新到最新版本?》来自Winter(https://github.com/aiyld/aiyld.github.io)的站点

1个回答
Winter 2018.10.29

See the docs for the update command:

npm update [ [ ...]]

This command will update all the packages listed to the latest version (specified by the tag config). It will also install missing packages.

Additionally, see the FAQ:

How do I update npm?

npm install -g npm

Please note that this command will remove your current version of npm. Make sure to use sudo npm install -g npm if on a Mac.

You can also update all outdated local packages by doing npm update without any arguments, or global packages by doing npm update -g.

Occasionally, the version of npm will progress such that the current version cannot be properly installed with the version that you have installed already. (Consider, if there is ever a bug in the update command.) In those cases, you can do this:

curl https://www.npmjs.com/install.sh | sh

To update Node.js itself, I recommend you use nvm, the Node Version Manager.

问题类别

JavaScript Ckeditor Python Webpack TypeScript Vue.js React.js ExpressJS KoaJS CSS Node.js HTML Django 单元测试 PHP Asp.net jQuery Bootstrap IOS Android