Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
377 views
in Technique[技术] by (71.8m points)

node.js - 如何将NodeJS和NPM更新到下一版本?(How can I update NodeJS and NPM to the next versions?)

I just installed Node.js and npm (for additional modules).

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

How can I update Node.js and the modules which I'm using to the latest versions?

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

Can npm do it, or do I have to remove and reinstall Node.js and npm to get the next versions?

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

I followed this steps in the npm section.

(我在npm部分中遵循了步骤。)

  ask by Dail translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

See the docs for the update command:

(有关update命令,请参阅文档:)

npm update [<name> [<name> ...]]

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

(此命令会将列出的所有软件包更新到最新版本(由标记config指定)。)

It will also install missing packages.

(它还将安装缺少的软件包。)

Additionally, see the documentation on Node.js and NPM installation and Upgrading NPM .

(此外,请参阅有关Node.js和NPM安装以及升级NPM的文档。)

The following original answer is from the old FAQ that no longer exists, but should work for Linux and Mac:

(以下原始答案来自不再存在的旧FAQ,但适用于Linux和Mac:)

How do I update npm? (如何更新npm?)

 npm install -g npm 

Please note that this command will remove your current version of npm.

(请注意,此命令将删除您当前的npm版本。)

Make sure to use sudo npm install -g npm if on a Mac.

(如果在Mac上,请确保使用sudo npm install -g npm 。)

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来更新所有过时的本地软件包,或者通过执行npm update -gnpm 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.

(有时,npm的版本会升级,导致当前版本无法与已经安装的版本正确安装。)

(Consider, if there is ever a bug in the update command.) In those cases, you can do this:

((考虑一下,如果update命令中存在错误。)在这种情况下,您可以这样做:)

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

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

(要更新Node.js本身,建议您使用nvm(节点版本管理器) 。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...