如何更新节点。js和npm的下一个版本?

时间:2021-04-26 07:27:42

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

我只是安装节点。js和npm(附加模块)。

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

如何更新节点。js和我在上一个版本中使用的模块?

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

npm能做到吗?或者我必须删除和重新安装节点。js和npm能得到下一个版本吗?

I followed https://github.com/nodejs/node/wiki/Installation and the next npm section.

我跟踪了https://github.com/nodejs/node/wiki/Installation和下一个npm部分。

32 个解决方案

#1


1322  

See the docs for the update command:

请参阅更新命令的文档:

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

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.

请注意,此命令将删除当前版本的npm。确保在Mac上使用sudo npm安装- gnpm。

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 -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:

有时候,npm的版本会取得进展,使当前版本不能正确安装到已经安装的版本中。(如果更新命令中存在bug,请考虑。)在这些情况下,你可以这样做:

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

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

更新节点。js本身,我建议您使用nvm,节点版本管理器。

#2


328  

I found this really neat way of updating node on David Walsh's blog, you can do it by installing n:

我在David Walsh的博客上发现了一个非常简洁的更新节点的方法,你可以通过安装n:

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

It will install the current stable version of node. However, I recommend using nvm.

它将安装当前稳定版本的节点。但是,我建议使用nvm。

#3


126  

Updating npm is easy:

更新npm很容易:

npm install npm@latest -g

#4


122  

I understand this question is for Linux machine but just in case anybody is looking for a Windows solution, just go to the Node.js site, click the download button on the homepage and execute the installer program.

我知道这个问题是针对Linux机器的,但如果有人想要Windows的解决方案,那就去Node。js站点,点击主页上的下载按钮,执行安装程序。

Thankfully it took care of everything and with a few clicks of 'Next' button I got the latest 0.8.15 Node.js version running on my Windows 7 machine.

幸运的是,它处理了所有的事情,点击“Next”按钮,我得到了最新的0.8.15节点。js版本运行在我的Windows 7机器上。

#5


95  

As you may know, NPM is currently bundled with Node.js, it means that if you have installed node you already have installed npm. There are several approaches to keep up to date the Node.js and NPM, you need to use one of the following version managers:

您可能知道,NPM目前与Node绑定在一起。js,意思是如果你已经安装了节点,你已经安装了npm。有几种方法可以保持更新节点的日期。js和NPM,您需要使用以下版本管理器之一:

Homebrew

If yo are on Mac, you can use Homebrew. To install NodeJS and NPM using brew:

如果你在Mac电脑上,你可以使用Homebrew。使用brew安装NodeJS和NPM:

$ brew install node

later you will be able to update it using

稍后您将能够使用它更新它。

$ brew update && brew upgrade node

NPM will be updated as well.

NPM也将被更新。

You also will be able to switch to the one of the previous versions if you need, for example:

如果需要,您还可以切换到以前的版本,例如:

$ brew switch node 0.10.26

To install brew to your Mac:

为你的Mac安装brew:

$ ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

N

n is most likely to rvm (Ruby Version Manager), and can be used to manage and update node/npm versions.

n很可能是rvm (Ruby版本管理器),可以用来管理和更新节点/npm版本。

Install Node.js versions easily:

安装节点。js版本很容易:

$ n 0.10.26
$ n 0.8.17
$ n 0.9.6

Use (and install if missing) the latest official release:

使用(并安装如果丢失)最新官方发布:

$ n latest

Use/install the stable official release:

使用/安装稳定的官方版本:

$ n stable

Switch to the previous version you were using:

切换到之前使用的版本:

$ n prev

If you want to see the list of installed nodes, just run n from your command line, the output will be something like the following:

如果希望查看已安装节点的列表,只需从命令行运行n,输出将如下所示:

$ n

  0.10.26
• 0.8.17
  0.9.6

The dot (•) means that it's a currently active version. To select a node version from the list use up and down arrows and activate using enter.

点(•)表示它是当前活动的版本。从列表中选择一个节点版本,使用上下箭头,并使用enter激活。

The n package is written on pure linux shell and available as a npm module (contains package.json), so if you have any Node.js installed, you can install/update the n through the npm:

这个n包是在纯linux shell上编写的,并且可以作为npm模块(包含package.json),所以如果您有任何节点。安装js,你可以通过npm安装/更新n:

$ npm install -g n

NVM

nvm is also like RVM, even the command names and usage are very similar.

nvm也像RVM,甚至命令名和用法也非常相似。

To download, compile, and install the latest v0.10.x release of the Node.js using nvm:

下载、编译和安装最新的v0.10。x释放节点。js使用nvm:

$ nvm install 0.10

And then you can switch to the installed version:

然后你可以切换到安装版本:

$ nvm use 0.10

You can create an .nvmrc file containing version number in the project root folder; then run the following command to switch to the specified version:

您可以在项目根目录中创建包含版本号的.nvmrc文件;然后运行以下命令切换到指定的版本:

$ nvm use

Or you can just run it:

或者你可以运行它:

$ nvm run 0.10

If you want to see which versions are already installed, use:

如果您想查看已经安装了哪些版本,请使用:

$ nvm ls

To install nvm itself you can use the install script (requires git) using cURL:

要安装nvm本身,您可以使用cURL来使用安装脚本(需要git):

$ curl https://raw.github.com/creationix/nvm/master/install.sh | sh

or wget:

或wget:

$ wget -qO- https://raw.github.com/creationix/nvm/master/install.sh | sh

P.S.

注:

All these approaches I've used on MacOSX and Linux, I don't have any experience on how to manage Node.js versions on Windows, I can only suppose that the n (the second one) will work for Microsoft's OS (at least from the cygwin).

我在MacOSX和Linux上使用的所有这些方法,我没有任何关于如何管理节点的经验。在Windows上的js版本,我只能假设n(第二种)将为微软的操作系统(至少是cygwin)工作。

#6


70  

First check your NPM version

npm -v

1) Update NPM to current version:

View curent NPM version:

观点颇NPM版本:

npm view npm version

Update npm to current version:

更新npm到当前版本:

npm i -g npm


2) List all available NPM versions and make a custom install/update/roll-back

View all versions including "alpha", "beta" and "rc" (release candidate)

查看所有版本,包括“alpha”、“beta”和“rc”(发布候选版本)

npm view npm versions --json

Reinstall NPM to a specific version chosen from the versions list - for example to 5.0.3

将NPM重新安装到从版本列表中选择的特定版本中——例如5.0.3。

npm i -g npm@5.0.3
  • Installing one version will automatically remove the one currently installed.

    安装一个版本会自动删除当前安装的版本。

  • For Linux and iOS prepend commands with sudo

    对于Linux和iOS prepend命令与sudo。

#7


48  

Upgrading for Windows Users

Windows users should read Troubleshooting > Upgrading on Windows in the npm wiki.

Windows用户应该在npm wiki上阅读bb0升级的故障排除。

Upgrading on windows 10 using PowerShell (3rd party edit)

The link above Troubleshooting#upgrading-on-windows points to a github page npm-windows-upgrade the lines below are quotes from the readme. I successfully upgraded from npm 2.7.4 to npm 3.9.3 using node v5.7.0 and powershell (presumably powershell version 5.0.10586.122)

上面的链接故障排除# upgradon -windows指向一个github页面npm-windows-升级下面的行是来自readme的引用。我使用节点v5.7.0和powershell成功地从npm 2.7.4升级到npm 3.9.3(可能是powershell版本5.0.10586.122)。

First, ensure that you can execute scripts on your system by running the following command from an elevated PowerShell. To run PowerShell as Administrator, click Start, search for PowerShell, right-click PowerShell and select Run as Administrator.

首先,确保您可以通过运行以下命令从高架的PowerShell中运行以下命令来执行系统脚本。要运行PowerShell作为管理员,单击Start,搜索PowerShell,右键单击PowerShell并选择run作为管理员。

Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force    

Then, to install and use this upgrader tool, run (also from an elevated PowerShell or cmd.exe):

然后,安装和使用这个升级工具,运行(同样来自一个高架PowerShell或cmd.exe):

npm install --global --production npm-windows-upgrade
npm-windows-upgrade

#8


30  

SIMPLY USE THIS

npm i -g npm

This is what i get promped on my console from npm when new update/bug-fix are released:

这是我在npm中从npm得到的消息,当新的更新/bug修复被发布时:

如何更新节点。js和npm的下一个版本?

#9


24  

  • To update node use nvm (or nvmw for windows).

    更新节点使用nvm(或windows的nvmw)。

  • To update npm, the npm update npm -g command didn't work for me (on windows). What did work was reinstalling npm according to the documentation: "You can download a zip file from https://npmjs.org/dist/, and unpack it in the same folder where node.exe lives." Make sure if you do this that you get rid of your previous installation first (though overwriting it will probably work ok...).

    为了更新npm, npm更新npm -g命令对我不起作用(在windows上)。根据文档,工作正在重新安装npm:“您可以从https://npmjs.org/dist/下载一个zip文件,并将其解压到节点所在的文件夹中。exe生活。”请确保您这样做是为了避免之前的安装(尽管过度编写可能会起作用)。

  • To update your modules, use the npm update command

    要更新您的模块,请使用npm更新命令。

#10


19  

First update npm,

第一个更新npm,

npm install -g npm@next

npm安装- g npm@next

Then update node to the next version,

然后更新节点到下一个版本,

npm install -g node@next or npm install -g n@next or, to the latest,

npm安装-g node@next或npm安装- gn@next或最新的,

npm install -g node@latest or npm install -g node

npm安装-g node@latest或npm安装-g节点。

check after version installation,

检查版本安装后,

node --versionor node -v

节点——versionor节点- v

#11


15  

$ npm install -g npm stable

Worked for me to update from 1.4.28 to 2.1.5

为我工作,从1.4.28更新到2.1.5。

#12


13  

I just installed Node.js on a new Windows 7 machine, with the following results:

我只是安装节点。js在一个新的Windows 7机器上,有以下结果:

> node -v
v0.12.0
> npm -v
2.5.1

I then did the above described procedure:

然后我做了上述描述的程序:

> npm install -g npm

and it upgraded to v2.7.3. Except than doing npm -v still gave 2.5.1.

升级到v2.7.3。除了npm -v还提供了2.5.1。

I went to the System configuration panel, advanced settings, environment variables. I saw a PATH variable specific to my user account, in addition to the global Path variable.
The former pointed to new npm: C:\Users\PhiLho\AppData\Roaming\npm
The latter includes the path to node: C:\PrgCmdLine\nodejs\ (Nowadays, I avoid to install stuff in Program Files and derivates. Avoiding spaces in paths, and noisy useless protections is saner...)
If I do which npm.cmd (I have Unix utilities installed...), it points to the one in Node.

我去了系统配置面板,高级设置,环境变量。除了全局路径变量之外,我还看到了特定于我的用户帐户的路径变量。前者指出新npm:C:\Users\PhiLho\AppData\Roaming\npm后者包括节点的路径:C:\ PrgCmdLine \ nodejs \(现在,我避免安装在程序文件和衍生物。避免在道路上的空间,和嘈杂的无用的保护是saner…如果我做了npm。cmd(我安装了Unix工具…),它指向节点中的一个。

Anyway, the fix is simple: I just copied the first path (to npm) just before the path to node in the main, global Path variable, and now it picks up the latest version.
<some stuff before>;C:\Users\PhiLho\AppData\Roaming\npm;C:\PrgCmdLine\nodejs\

无论如何,解决方法很简单:我只是在main全局路径变量的路径之前复制了第一个路径(到npm),现在它选择了最新的版本。< >之前一些东西;C:\ \ PhiLho \ AppData \漫游用户\ npm;C:\ PrgCmdLine \ nodejs \

> npm -v
2.7.3

Enjoy. :-)

享受。:-)

#13


10  

For Linux, OSX, etc..

Linux,OSX等等. .

To install the latest version of NPM

安装最新版本的NPM。

npm install -g npm@latest

npm安装- g npm@latest

Or To Install the most recent release

或者安装最新版本。

npm install -g npm@next

npm安装- g npm@next

Additional : To check your npm version

附加:检查您的npm版本。

npm -v

npm - v

If you are in a Windows Machine, I suggest going to the npm website

如果你是在Windows机器里,我建议你去npm网站。

#14


10  

Just run the following command in terminal as root/administrator:

在terminal中运行以下命令作为根/管理员:

npm i -g n
n stable
npm update -g npm

It has worked for me on Linux

它在Linux上为我工作。

#15


9  

Install npm => sudo apt-get install npm

安装npm => sudo apt-get安装npm。

Install n => sudo npm install n -g

安装n => sudo npm安装n -g。

latest version of node => sudo n latest

最新版本的node => sudo n最新版本。

Specific version of node you can

特定版本的节点你可以。

List available node versions => n ls

列表可用节点版本=> n ls。

Install a specific version => sudo n 4.5.0

安装一个特定的版本=> sudo n4.5.0。

#16


8  

I recently stumbled across this article: http://martineau.tv/blog/2013/12/more-efficient-grunt-workflows/ and the author mentions $ npm-check-updates -u && npm install to update all dependencies.

我最近偶然发现了这篇文章:http://martineau。tv/blog/2013/12/更有效率-grunt-workflow /和作者提到$ npm-check-update -u && npm安装来更新所有依赖项。

This is a little off the topic but I ended up here on a similar search so thought it was worth the share.

这个话题有点离题了,但我还是在这里做了一个类似的搜索,所以我认为它值得分享。

#17


8  

Sometimes it's just simpler to download the latest version from http://nodejs.org/

有时候,从http://nodejs.org/下载最新版本更简单。

Especially when all other options fail.

尤其是当所有其他选项都失败的时候。

http://nodejs.org/ -> click INSTALL -> you'll have the latest node and npm

http://nodejs.org/ ->点击安装->你将拥有最新的节点和npm。

Simple!

简单!

#18


8  

Just listened to an interview with the npm team on the latest episode of nodeup, and they recommended not using update for the update from 1.x to 2.x. Instead, use: npm install npm -g

刚刚听取了npm团队关于最新一期nodeup的采访,他们建议不要使用更新的更新从1。x 2. x。相反,使用:npm安装npm -g。

#19


7  

Just with this code

只是这段代码

npm install update

#20


7  

To update npm :

更新npm:

npm install npm@{version} -g

to update npm to the latest version:

更新npm到最新版本:

npm install npm@latest -g

and to check the version :

并检查版本:

npm -v

to update node js :

更新节点js:

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

to check :

检查:

node -v

#21


5  

For Cygwin users:

Cygwin用户:

Installing n (node version manager) in Cygwin doesn't work, instead update node with:

在Cygwin中安装n(节点版本管理器)不工作,而是更新节点:

wget https://nodejs.org/download/release/latest/win-x64/node.exe -OutFile 'C:\pathto\nodejs\node.exe'
# Updating npm
npm i -g npm

Yes, you need to install wget first.

是的,你需要先安装wget。

#22


4  

Also if you want to update to a particular version, follow this:

如果您想要更新到特定的版本,请遵循以下步骤:

sudo npm cache clean -f
sudo npm install -g n
sudo n <specific version>

#23


4  

Use n module from npm in order to upgrade node . n is a node helper package that installs or updates a given node.js version.

从npm中使用n模块来升级节点。n是安装或更新给定节点的节点助手包。js版本。

sudo npm cache clean -f
sudo npm install -g n
sudo n stable
sudo ln -sf /usr/local/n/versions/node/<VERSION>/bin/node /usr/bin/nodejs

NOTE that the default installation for nodejs is in the /usr/bin/nodejs and not /usr/bin/node

注意,nodejs的默认安装在/usr/bin/nodejs中,而不是/usr/bin/node。

To upgrade to latest version (and not current stable) version, you can use

要升级到最新版本(而不是当前稳定版本),您可以使用。

sudo n latest

sudo n最新

To undo:

撤销:

sudo apt-get install --reinstall nodejs-legacy     # fix /usr/bin/node
sudo n rm 6.0.0     # replace number with version of Node that was installed
sudo npm uninstall -g n

If you get the following error bash: /usr/bin/node: No such file or directory then the path you have entered at

如果您得到以下错误:/usr/bin/node:没有这样的文件或目录,那么您输入的路径。

sudo ln -sf /usr/local/n/versions/node/<VERSION>/bin/node /usr/bin/nodejs

if wrong. so make sure to check if the update nodejs has been installed at the above path and the version you are entered is correct.

如果错了。因此,请确保检查更新nodejs是否已安装在上述路径上,并且您所输入的版本是否正确。

I would advise strongly against doing this on a production instance. It can seriously mess stuff up with your global npm packages and your ability to install new one.

我强烈建议不要在生产实例上这样做。它可能会严重破坏你的全局npm包和你安装新软件包的能力。

#24


2  

Just run the below scripts on console:

在控制台运行下面的脚本:

sudo npm i -g n
sudo n stable
sudo npm update -g npm

This will work for Linux and MAC only

这只适用于Linux和MAC。

#25


2  

If you don't want to update to the latest version. Do this command:

如果您不想更新到最新版本。做这个命令:

npm install npm@4.2.0 -g

npm安装npm@4.2.0 - g

Replace 4.2.0 with whatever version you want. Here are all the release versions by Oct 3rd 2017: https://nodejs.org/en/download/releases/

用你想要的版本替换4.2.0。以下是2017年10月3日发布的所有版本:https://nodejs.org/en/download/releases/。

#26


2  

Here is a simple fix for those who installed node via Homebrew without npm and later on struggled with npm upgrade/installation using an official script. This approach assumes you have run the node installation as follows:

对于那些在没有npm的情况下通过自制程序安装节点的人来说,这是一个简单的解决方案,之后他们还会使用官方的脚本进行npm升级/安装。此方法假设您已经运行了节点安装:

brew install node --without-npm
echo prefix=~/.npm-packages >> ~/.npmrc
curl -L https://www.npmjs.com/install.sh | sh

If above failed then start from here. Remove npm if any:

如果上面失败了,那么从这里开始。删除npm如果任何:

rm -rf ~/.npm-packages/lib/node_modules/npm

Download and unpack the latest version of npm, currently at 5.6.0:

下载和解压最新版本的npm,目前为5.6.0:

cd ~
curl -L https://registry.npmjs.org/npm/-/npm-5.6.0.tgz | tar xz

Move unpacked package into node_modules folder:

将未打包的包移动到node_modules文件夹:

mv ~/package ~/.npm-packages/lib/node_modules/npm

Make sure your ~/.bash_profile has following entries:

确保你的~ /。bash_profile以下条目:

export NPM_PACKAGES="$HOME/.npm-packages"
export NODE_PATH="$NPM_PACKAGES/lib/node_modules:$NODE_PATH"
export PATH="$NPM_PACKAGES/bin:$PATH"

Source the file:

源文件:

source ~/.bash_profile

Verify installation:

验证安装:

npm -v

#27


1  

I have developed a very simple and fast package to do this kind of update, atualiza can deal with global and project packages. In the later you can choose between the newest version or the bigger version that matches your current package.json's rule. For global packages you don't have a rule so atualiza will upgrade to newest always.

我开发了一个非常简单和快速的包来做这种更新,阿图利萨可以处理全局和项目包。在后面,您可以在最新版本或更大的版本中选择与当前包相匹配的版本。json的统治。对于全球软件包,你没有一个规则,所以阿图利萨将升级到最新。

#28


1  

Personally I use nvm (Node Version Manager) which is a simple bash script to manage multiple active node.js versions and you can have multiple versions of node and global modules configured for different users at the same time.

我个人使用nvm(节点版本管理器),它是一个简单的bash脚本,用于管理多个活动节点。js版本和您可以同时为不同的用户配置多个版本的节点和全局模块。

You can check at this link: nvm

你可以查看这个链接:nvm。

Also there is a windows version nvm-windows

还有一个windows版本的nvm-windows。

#29


1  

If you're using Windows: Go to https://nodejs.org/en/download/, download latest .exe or .msi file and install to overwrite the old versions

如果您正在使用Windows:请访问https://nodejs.org/en/download/,下载最新的.exe或.msi文件并安装以覆盖旧版本。

If you're using Ubuntu or Linux: Uninstall node.js first then reinstall, e.g with Ubuntu ():

如果您正在使用Ubuntu或Linux:卸载节点。js首先重新安装,e。g Ubuntu():

sudo apt-get remove nodejs

# assume node.js 8 is latest version
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install nodejs

node -v
npm -v

Remove node_modules in your project folder and npm install to make sure your application will run well on new node and npm version.

在您的项目文件夹和npm安装中删除node_modules,以确保您的应用程序在新节点和npm版本上运行良好。

#30


1  

you should see this blog nodejs install with package-manager

您应该看到这个博客nodejs安装了包管理器。

Before you performance this command. you show run sudo apt-get update, make sure result is Reading package lists... Done, no ERROR

在执行此命令之前。您显示运行sudo apt-get更新,确保结果是读取包列表…完成,没有错误

Step by Step (Debian):

一步一步(Debian):

sudo apt-get update

install 6_x

安装6个值

curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs

install 7_x

安装7值

curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install -y nodejs

#1


1322  

See the docs for the update command:

请参阅更新命令的文档:

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

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.

请注意,此命令将删除当前版本的npm。确保在Mac上使用sudo npm安装- gnpm。

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 -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:

有时候,npm的版本会取得进展,使当前版本不能正确安装到已经安装的版本中。(如果更新命令中存在bug,请考虑。)在这些情况下,你可以这样做:

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

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

更新节点。js本身,我建议您使用nvm,节点版本管理器。

#2


328  

I found this really neat way of updating node on David Walsh's blog, you can do it by installing n:

我在David Walsh的博客上发现了一个非常简洁的更新节点的方法,你可以通过安装n:

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

It will install the current stable version of node. However, I recommend using nvm.

它将安装当前稳定版本的节点。但是,我建议使用nvm。

#3


126  

Updating npm is easy:

更新npm很容易:

npm install npm@latest -g

#4


122  

I understand this question is for Linux machine but just in case anybody is looking for a Windows solution, just go to the Node.js site, click the download button on the homepage and execute the installer program.

我知道这个问题是针对Linux机器的,但如果有人想要Windows的解决方案,那就去Node。js站点,点击主页上的下载按钮,执行安装程序。

Thankfully it took care of everything and with a few clicks of 'Next' button I got the latest 0.8.15 Node.js version running on my Windows 7 machine.

幸运的是,它处理了所有的事情,点击“Next”按钮,我得到了最新的0.8.15节点。js版本运行在我的Windows 7机器上。

#5


95  

As you may know, NPM is currently bundled with Node.js, it means that if you have installed node you already have installed npm. There are several approaches to keep up to date the Node.js and NPM, you need to use one of the following version managers:

您可能知道,NPM目前与Node绑定在一起。js,意思是如果你已经安装了节点,你已经安装了npm。有几种方法可以保持更新节点的日期。js和NPM,您需要使用以下版本管理器之一:

Homebrew

If yo are on Mac, you can use Homebrew. To install NodeJS and NPM using brew:

如果你在Mac电脑上,你可以使用Homebrew。使用brew安装NodeJS和NPM:

$ brew install node

later you will be able to update it using

稍后您将能够使用它更新它。

$ brew update && brew upgrade node

NPM will be updated as well.

NPM也将被更新。

You also will be able to switch to the one of the previous versions if you need, for example:

如果需要,您还可以切换到以前的版本,例如:

$ brew switch node 0.10.26

To install brew to your Mac:

为你的Mac安装brew:

$ ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

N

n is most likely to rvm (Ruby Version Manager), and can be used to manage and update node/npm versions.

n很可能是rvm (Ruby版本管理器),可以用来管理和更新节点/npm版本。

Install Node.js versions easily:

安装节点。js版本很容易:

$ n 0.10.26
$ n 0.8.17
$ n 0.9.6

Use (and install if missing) the latest official release:

使用(并安装如果丢失)最新官方发布:

$ n latest

Use/install the stable official release:

使用/安装稳定的官方版本:

$ n stable

Switch to the previous version you were using:

切换到之前使用的版本:

$ n prev

If you want to see the list of installed nodes, just run n from your command line, the output will be something like the following:

如果希望查看已安装节点的列表,只需从命令行运行n,输出将如下所示:

$ n

  0.10.26
• 0.8.17
  0.9.6

The dot (•) means that it's a currently active version. To select a node version from the list use up and down arrows and activate using enter.

点(•)表示它是当前活动的版本。从列表中选择一个节点版本,使用上下箭头,并使用enter激活。

The n package is written on pure linux shell and available as a npm module (contains package.json), so if you have any Node.js installed, you can install/update the n through the npm:

这个n包是在纯linux shell上编写的,并且可以作为npm模块(包含package.json),所以如果您有任何节点。安装js,你可以通过npm安装/更新n:

$ npm install -g n

NVM

nvm is also like RVM, even the command names and usage are very similar.

nvm也像RVM,甚至命令名和用法也非常相似。

To download, compile, and install the latest v0.10.x release of the Node.js using nvm:

下载、编译和安装最新的v0.10。x释放节点。js使用nvm:

$ nvm install 0.10

And then you can switch to the installed version:

然后你可以切换到安装版本:

$ nvm use 0.10

You can create an .nvmrc file containing version number in the project root folder; then run the following command to switch to the specified version:

您可以在项目根目录中创建包含版本号的.nvmrc文件;然后运行以下命令切换到指定的版本:

$ nvm use

Or you can just run it:

或者你可以运行它:

$ nvm run 0.10

If you want to see which versions are already installed, use:

如果您想查看已经安装了哪些版本,请使用:

$ nvm ls

To install nvm itself you can use the install script (requires git) using cURL:

要安装nvm本身,您可以使用cURL来使用安装脚本(需要git):

$ curl https://raw.github.com/creationix/nvm/master/install.sh | sh

or wget:

或wget:

$ wget -qO- https://raw.github.com/creationix/nvm/master/install.sh | sh

P.S.

注:

All these approaches I've used on MacOSX and Linux, I don't have any experience on how to manage Node.js versions on Windows, I can only suppose that the n (the second one) will work for Microsoft's OS (at least from the cygwin).

我在MacOSX和Linux上使用的所有这些方法,我没有任何关于如何管理节点的经验。在Windows上的js版本,我只能假设n(第二种)将为微软的操作系统(至少是cygwin)工作。

#6


70  

First check your NPM version

npm -v

1) Update NPM to current version:

View curent NPM version:

观点颇NPM版本:

npm view npm version

Update npm to current version:

更新npm到当前版本:

npm i -g npm


2) List all available NPM versions and make a custom install/update/roll-back

View all versions including "alpha", "beta" and "rc" (release candidate)

查看所有版本,包括“alpha”、“beta”和“rc”(发布候选版本)

npm view npm versions --json

Reinstall NPM to a specific version chosen from the versions list - for example to 5.0.3

将NPM重新安装到从版本列表中选择的特定版本中——例如5.0.3。

npm i -g npm@5.0.3
  • Installing one version will automatically remove the one currently installed.

    安装一个版本会自动删除当前安装的版本。

  • For Linux and iOS prepend commands with sudo

    对于Linux和iOS prepend命令与sudo。

#7


48  

Upgrading for Windows Users

Windows users should read Troubleshooting > Upgrading on Windows in the npm wiki.

Windows用户应该在npm wiki上阅读bb0升级的故障排除。

Upgrading on windows 10 using PowerShell (3rd party edit)

The link above Troubleshooting#upgrading-on-windows points to a github page npm-windows-upgrade the lines below are quotes from the readme. I successfully upgraded from npm 2.7.4 to npm 3.9.3 using node v5.7.0 and powershell (presumably powershell version 5.0.10586.122)

上面的链接故障排除# upgradon -windows指向一个github页面npm-windows-升级下面的行是来自readme的引用。我使用节点v5.7.0和powershell成功地从npm 2.7.4升级到npm 3.9.3(可能是powershell版本5.0.10586.122)。

First, ensure that you can execute scripts on your system by running the following command from an elevated PowerShell. To run PowerShell as Administrator, click Start, search for PowerShell, right-click PowerShell and select Run as Administrator.

首先,确保您可以通过运行以下命令从高架的PowerShell中运行以下命令来执行系统脚本。要运行PowerShell作为管理员,单击Start,搜索PowerShell,右键单击PowerShell并选择run作为管理员。

Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force    

Then, to install and use this upgrader tool, run (also from an elevated PowerShell or cmd.exe):

然后,安装和使用这个升级工具,运行(同样来自一个高架PowerShell或cmd.exe):

npm install --global --production npm-windows-upgrade
npm-windows-upgrade

#8


30  

SIMPLY USE THIS

npm i -g npm

This is what i get promped on my console from npm when new update/bug-fix are released:

这是我在npm中从npm得到的消息,当新的更新/bug修复被发布时:

如何更新节点。js和npm的下一个版本?

#9


24  

  • To update node use nvm (or nvmw for windows).

    更新节点使用nvm(或windows的nvmw)。

  • To update npm, the npm update npm -g command didn't work for me (on windows). What did work was reinstalling npm according to the documentation: "You can download a zip file from https://npmjs.org/dist/, and unpack it in the same folder where node.exe lives." Make sure if you do this that you get rid of your previous installation first (though overwriting it will probably work ok...).

    为了更新npm, npm更新npm -g命令对我不起作用(在windows上)。根据文档,工作正在重新安装npm:“您可以从https://npmjs.org/dist/下载一个zip文件,并将其解压到节点所在的文件夹中。exe生活。”请确保您这样做是为了避免之前的安装(尽管过度编写可能会起作用)。

  • To update your modules, use the npm update command

    要更新您的模块,请使用npm更新命令。

#10


19  

First update npm,

第一个更新npm,

npm install -g npm@next

npm安装- g npm@next

Then update node to the next version,

然后更新节点到下一个版本,

npm install -g node@next or npm install -g n@next or, to the latest,

npm安装-g node@next或npm安装- gn@next或最新的,

npm install -g node@latest or npm install -g node

npm安装-g node@latest或npm安装-g节点。

check after version installation,

检查版本安装后,

node --versionor node -v

节点——versionor节点- v

#11


15  

$ npm install -g npm stable

Worked for me to update from 1.4.28 to 2.1.5

为我工作,从1.4.28更新到2.1.5。

#12


13  

I just installed Node.js on a new Windows 7 machine, with the following results:

我只是安装节点。js在一个新的Windows 7机器上,有以下结果:

> node -v
v0.12.0
> npm -v
2.5.1

I then did the above described procedure:

然后我做了上述描述的程序:

> npm install -g npm

and it upgraded to v2.7.3. Except than doing npm -v still gave 2.5.1.

升级到v2.7.3。除了npm -v还提供了2.5.1。

I went to the System configuration panel, advanced settings, environment variables. I saw a PATH variable specific to my user account, in addition to the global Path variable.
The former pointed to new npm: C:\Users\PhiLho\AppData\Roaming\npm
The latter includes the path to node: C:\PrgCmdLine\nodejs\ (Nowadays, I avoid to install stuff in Program Files and derivates. Avoiding spaces in paths, and noisy useless protections is saner...)
If I do which npm.cmd (I have Unix utilities installed...), it points to the one in Node.

我去了系统配置面板,高级设置,环境变量。除了全局路径变量之外,我还看到了特定于我的用户帐户的路径变量。前者指出新npm:C:\Users\PhiLho\AppData\Roaming\npm后者包括节点的路径:C:\ PrgCmdLine \ nodejs \(现在,我避免安装在程序文件和衍生物。避免在道路上的空间,和嘈杂的无用的保护是saner…如果我做了npm。cmd(我安装了Unix工具…),它指向节点中的一个。

Anyway, the fix is simple: I just copied the first path (to npm) just before the path to node in the main, global Path variable, and now it picks up the latest version.
<some stuff before>;C:\Users\PhiLho\AppData\Roaming\npm;C:\PrgCmdLine\nodejs\

无论如何,解决方法很简单:我只是在main全局路径变量的路径之前复制了第一个路径(到npm),现在它选择了最新的版本。< >之前一些东西;C:\ \ PhiLho \ AppData \漫游用户\ npm;C:\ PrgCmdLine \ nodejs \

> npm -v
2.7.3

Enjoy. :-)

享受。:-)

#13


10  

For Linux, OSX, etc..

Linux,OSX等等. .

To install the latest version of NPM

安装最新版本的NPM。

npm install -g npm@latest

npm安装- g npm@latest

Or To Install the most recent release

或者安装最新版本。

npm install -g npm@next

npm安装- g npm@next

Additional : To check your npm version

附加:检查您的npm版本。

npm -v

npm - v

If you are in a Windows Machine, I suggest going to the npm website

如果你是在Windows机器里,我建议你去npm网站。

#14


10  

Just run the following command in terminal as root/administrator:

在terminal中运行以下命令作为根/管理员:

npm i -g n
n stable
npm update -g npm

It has worked for me on Linux

它在Linux上为我工作。

#15


9  

Install npm => sudo apt-get install npm

安装npm => sudo apt-get安装npm。

Install n => sudo npm install n -g

安装n => sudo npm安装n -g。

latest version of node => sudo n latest

最新版本的node => sudo n最新版本。

Specific version of node you can

特定版本的节点你可以。

List available node versions => n ls

列表可用节点版本=> n ls。

Install a specific version => sudo n 4.5.0

安装一个特定的版本=> sudo n4.5.0。

#16


8  

I recently stumbled across this article: http://martineau.tv/blog/2013/12/more-efficient-grunt-workflows/ and the author mentions $ npm-check-updates -u && npm install to update all dependencies.

我最近偶然发现了这篇文章:http://martineau。tv/blog/2013/12/更有效率-grunt-workflow /和作者提到$ npm-check-update -u && npm安装来更新所有依赖项。

This is a little off the topic but I ended up here on a similar search so thought it was worth the share.

这个话题有点离题了,但我还是在这里做了一个类似的搜索,所以我认为它值得分享。

#17


8  

Sometimes it's just simpler to download the latest version from http://nodejs.org/

有时候,从http://nodejs.org/下载最新版本更简单。

Especially when all other options fail.

尤其是当所有其他选项都失败的时候。

http://nodejs.org/ -> click INSTALL -> you'll have the latest node and npm

http://nodejs.org/ ->点击安装->你将拥有最新的节点和npm。

Simple!

简单!

#18


8  

Just listened to an interview with the npm team on the latest episode of nodeup, and they recommended not using update for the update from 1.x to 2.x. Instead, use: npm install npm -g

刚刚听取了npm团队关于最新一期nodeup的采访,他们建议不要使用更新的更新从1。x 2. x。相反,使用:npm安装npm -g。

#19


7  

Just with this code

只是这段代码

npm install update

#20


7  

To update npm :

更新npm:

npm install npm@{version} -g

to update npm to the latest version:

更新npm到最新版本:

npm install npm@latest -g

and to check the version :

并检查版本:

npm -v

to update node js :

更新节点js:

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

to check :

检查:

node -v

#21


5  

For Cygwin users:

Cygwin用户:

Installing n (node version manager) in Cygwin doesn't work, instead update node with:

在Cygwin中安装n(节点版本管理器)不工作,而是更新节点:

wget https://nodejs.org/download/release/latest/win-x64/node.exe -OutFile 'C:\pathto\nodejs\node.exe'
# Updating npm
npm i -g npm

Yes, you need to install wget first.

是的,你需要先安装wget。

#22


4  

Also if you want to update to a particular version, follow this:

如果您想要更新到特定的版本,请遵循以下步骤:

sudo npm cache clean -f
sudo npm install -g n
sudo n <specific version>

#23


4  

Use n module from npm in order to upgrade node . n is a node helper package that installs or updates a given node.js version.

从npm中使用n模块来升级节点。n是安装或更新给定节点的节点助手包。js版本。

sudo npm cache clean -f
sudo npm install -g n
sudo n stable
sudo ln -sf /usr/local/n/versions/node/<VERSION>/bin/node /usr/bin/nodejs

NOTE that the default installation for nodejs is in the /usr/bin/nodejs and not /usr/bin/node

注意,nodejs的默认安装在/usr/bin/nodejs中,而不是/usr/bin/node。

To upgrade to latest version (and not current stable) version, you can use

要升级到最新版本(而不是当前稳定版本),您可以使用。

sudo n latest

sudo n最新

To undo:

撤销:

sudo apt-get install --reinstall nodejs-legacy     # fix /usr/bin/node
sudo n rm 6.0.0     # replace number with version of Node that was installed
sudo npm uninstall -g n

If you get the following error bash: /usr/bin/node: No such file or directory then the path you have entered at

如果您得到以下错误:/usr/bin/node:没有这样的文件或目录,那么您输入的路径。

sudo ln -sf /usr/local/n/versions/node/<VERSION>/bin/node /usr/bin/nodejs

if wrong. so make sure to check if the update nodejs has been installed at the above path and the version you are entered is correct.

如果错了。因此,请确保检查更新nodejs是否已安装在上述路径上,并且您所输入的版本是否正确。

I would advise strongly against doing this on a production instance. It can seriously mess stuff up with your global npm packages and your ability to install new one.

我强烈建议不要在生产实例上这样做。它可能会严重破坏你的全局npm包和你安装新软件包的能力。

#24


2  

Just run the below scripts on console:

在控制台运行下面的脚本:

sudo npm i -g n
sudo n stable
sudo npm update -g npm

This will work for Linux and MAC only

这只适用于Linux和MAC。

#25


2  

If you don't want to update to the latest version. Do this command:

如果您不想更新到最新版本。做这个命令:

npm install npm@4.2.0 -g

npm安装npm@4.2.0 - g

Replace 4.2.0 with whatever version you want. Here are all the release versions by Oct 3rd 2017: https://nodejs.org/en/download/releases/

用你想要的版本替换4.2.0。以下是2017年10月3日发布的所有版本:https://nodejs.org/en/download/releases/。

#26


2  

Here is a simple fix for those who installed node via Homebrew without npm and later on struggled with npm upgrade/installation using an official script. This approach assumes you have run the node installation as follows:

对于那些在没有npm的情况下通过自制程序安装节点的人来说,这是一个简单的解决方案,之后他们还会使用官方的脚本进行npm升级/安装。此方法假设您已经运行了节点安装:

brew install node --without-npm
echo prefix=~/.npm-packages >> ~/.npmrc
curl -L https://www.npmjs.com/install.sh | sh

If above failed then start from here. Remove npm if any:

如果上面失败了,那么从这里开始。删除npm如果任何:

rm -rf ~/.npm-packages/lib/node_modules/npm

Download and unpack the latest version of npm, currently at 5.6.0:

下载和解压最新版本的npm,目前为5.6.0:

cd ~
curl -L https://registry.npmjs.org/npm/-/npm-5.6.0.tgz | tar xz

Move unpacked package into node_modules folder:

将未打包的包移动到node_modules文件夹:

mv ~/package ~/.npm-packages/lib/node_modules/npm

Make sure your ~/.bash_profile has following entries:

确保你的~ /。bash_profile以下条目:

export NPM_PACKAGES="$HOME/.npm-packages"
export NODE_PATH="$NPM_PACKAGES/lib/node_modules:$NODE_PATH"
export PATH="$NPM_PACKAGES/bin:$PATH"

Source the file:

源文件:

source ~/.bash_profile

Verify installation:

验证安装:

npm -v

#27


1  

I have developed a very simple and fast package to do this kind of update, atualiza can deal with global and project packages. In the later you can choose between the newest version or the bigger version that matches your current package.json's rule. For global packages you don't have a rule so atualiza will upgrade to newest always.

我开发了一个非常简单和快速的包来做这种更新,阿图利萨可以处理全局和项目包。在后面,您可以在最新版本或更大的版本中选择与当前包相匹配的版本。json的统治。对于全球软件包,你没有一个规则,所以阿图利萨将升级到最新。

#28


1  

Personally I use nvm (Node Version Manager) which is a simple bash script to manage multiple active node.js versions and you can have multiple versions of node and global modules configured for different users at the same time.

我个人使用nvm(节点版本管理器),它是一个简单的bash脚本,用于管理多个活动节点。js版本和您可以同时为不同的用户配置多个版本的节点和全局模块。

You can check at this link: nvm

你可以查看这个链接:nvm。

Also there is a windows version nvm-windows

还有一个windows版本的nvm-windows。

#29


1  

If you're using Windows: Go to https://nodejs.org/en/download/, download latest .exe or .msi file and install to overwrite the old versions

如果您正在使用Windows:请访问https://nodejs.org/en/download/,下载最新的.exe或.msi文件并安装以覆盖旧版本。

If you're using Ubuntu or Linux: Uninstall node.js first then reinstall, e.g with Ubuntu ():

如果您正在使用Ubuntu或Linux:卸载节点。js首先重新安装,e。g Ubuntu():

sudo apt-get remove nodejs

# assume node.js 8 is latest version
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install nodejs

node -v
npm -v

Remove node_modules in your project folder and npm install to make sure your application will run well on new node and npm version.

在您的项目文件夹和npm安装中删除node_modules,以确保您的应用程序在新节点和npm版本上运行良好。

#30


1  

you should see this blog nodejs install with package-manager

您应该看到这个博客nodejs安装了包管理器。

Before you performance this command. you show run sudo apt-get update, make sure result is Reading package lists... Done, no ERROR

在执行此命令之前。您显示运行sudo apt-get更新,确保结果是读取包列表…完成,没有错误

Step by Step (Debian):

一步一步(Debian):

sudo apt-get update

install 6_x

安装6个值

curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs

install 7_x

安装7值

curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install -y nodejs