How do I update Node.js?

2019-01-01 02:53发布

I did the following to update my npm:

npm update npm -g

But I have no idea how to update Node.js. Any suggestions? (I'm using Node.js 0.4.1 and want to update to Node.js 0.6.1.)

30条回答
浪荡孟婆
2楼-- · 2019-01-01 03:01

Use Node Version Manager (NVM)

It's a Bash script that lets you download and manage different versions of node. Full source code is here.

There is a separate project for nvm for Windows: github.com/coreybutler/nvm-windows

查看更多
弹指情弦暗扣
3楼-- · 2019-01-01 03:01

To upgrade node to the latest version or to a specific version you can do the following:

sudo npm install n -g
sudo n 0.10.18   // This will give you the specific version

For the latest stable version:

sudo n stable
查看更多
旧人旧事旧时光
4楼-- · 2019-01-01 03:01

Short & stupid answer:

Go to this page: Download | Node.js

Download the installer for your platform, then install it.

查看更多
深知你不懂我心
5楼-- · 2019-01-01 03:03

First update npm,

npm install -g npm stable

Then update node,

npm install -g node or npm install -g n

check after version installation,

node --versionor node -v

查看更多
牵手、夕阳
6楼-- · 2019-01-01 03:04

This is a simple solution that works for all supported operating systems* including Windows:

After a lot of surfing and not finding a straight solution, I just tried going to Node.js site, clicked the DOWNLOADS button on homepage and executed the installer program (MSI).

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

(here is the original answer)

For Docker users, here's the official Node.js image.


PS: To check your Node version use npm version or node --version.
PPS: Keep an eye on NodeJS blog - Vulnerabilities so you don't miss important security releases.

* Operating systems supported by Node.js: Windows, Linux, MacOS, SunOS, IBM AIX

查看更多
何处买醉
7楼-- · 2019-01-01 03:04

On CentOS 7 you can do the following:

sudo npm cache clean -f
sudo npm install -g n
sudo n stable
sudo ln -sf /usr/local/n/versions/node/5.4.1/bin/node /usr/bin/node
node –v (Should show updated version now)
npm rebuild node-sass (Optional: if you use this)

Note: The symlink is required to link your node binary with the latest Node.js installed binary file.

查看更多
登录 后发表回答