如何将NodeJS和NPM更新到下一版本? [英] How can I update NodeJS and NPM to the next versions?
问题描述
我刚刚安装了Node.js
和npm
(用于其他模块).
I just installed Node.js
and npm
(for additional modules).
如何将Node.js和正在使用的模块更新到最新版本?
How can I update Node.js and the modules which I'm using to the latest versions?
npm
可以这样做吗,还是必须删除并重新安装Node.js和npm才能获得下一个版本?
Can npm
do it, or do I have to remove and reinstall Node.js and npm to get the next versions?
我遵循了npm
部分中的此步骤.
I followed this steps in the npm
section.
推荐答案
请参见 update
命令:
npm update [-g] [<pkg>...]
此命令会将所有列出的软件包更新到最新版本(由标记config指定),同时注意使用semver.
This command will update all the packages listed to the latest version (specified by the tag config), respecting semver.
此外,请参见 Node.js和NPM安装上的文档和升级NPM .
以下原始答案来自不再存在的旧FAQ,但适用于Linux和Mac:
The following original answer is from the old FAQ that no longer exists, but should work for Linux and Mac:
如何更新npm?
npm install -g npm
请注意,此命令将删除您当前的npm版本.如果在Mac上,请确保使用sudo 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.
您还可以通过执行不带任何参数的npm update
来更新所有过时的本地程序包,或者通过执行npm update -g
来更新全局程序包.
You can also update all outdated local packages by doing npm update
without any arguments, or global packages by doing npm update -g
.
有时,npm的版本会升级,因此当前版本无法与已经安装的版本正确安装. (考虑一下,如果update命令中存在错误.)在这种情况下,您可以执行以下操作:
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
要更新Node.js本身,建议您使用 nvm,节点版本管理器.
To update Node.js itself, I recommend you use nvm, the Node Version Manager.
这篇关于如何将NodeJS和NPM更新到下一版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!