如何将 NodeJS 和 NPM 更新到下一个版本? [英] How can I update NodeJS and NPM to the next versions?
问题描述
我刚刚安装了 Node.js
和 npm
(用于附加模块).
如何将 Node.js 和我使用的模块更新到最新版本?
npm
可以吗,还是我必须删除并重新安装 Node.js 和 npm 才能获得下一个版本?
我遵循了 npm
部分中的 this 步骤.
查看 的文档update
命令:
npm update [-g] [...]
<块引用>
此命令会将列出的所有软件包更新为最新版本(由标签配置指定),尊重 semver.
此外,请参阅有关 Node.js 和 NPM 安装的文档 和 升级 NPM.
以下原始答案来自不再存在的旧常见问题解答,但应该适用于 Linux 和 Mac:
<块引用>如何更新 npm?
npm install -g npm
请注意,此命令将删除您当前的 npm 版本.如果在 Mac 上,请确保使用 sudo npm install -g npm
.
您还可以通过不带任何参数的 npm update
更新所有过时的本地包,或者通过执行 npm update -g
来更新全局包.
有时,npm 的版本会进步,以至于当前版本无法与您已经安装的版本一起正确安装.(考虑一下,如果更新命令中存在错误.)在这些情况下,您可以这样做:
curl https://www.npmjs.com/install.sh |嘘
要更新 Node.js 本身,我建议您使用 nvm,节点版本管理器.>
I just installed Node.js
and npm
(for additional modules).
How can I update Node.js and the modules which I'm using to the latest versions?
Can npm
do it, or do I have to remove and reinstall Node.js and npm to get the next versions?
I followed this steps in the npm
section.
See the docs for the update
command:
npm update [-g] [<pkg>...]
This command will update all the packages listed to the latest version (specified by the tag config), respecting semver.
Additionally, see the documentation on Node.js and NPM installation and Upgrading NPM.
The following original answer is from the old FAQ that no longer exists, but should work for Linux and Mac:
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 doingnpm 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.
这篇关于如何将 NodeJS 和 NPM 更新到下一个版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!