742

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.)

1

30 Answers 30

1893

To upgrade Node you may first want to see which version of Node.js you are currently using:

node --version 

Find out which versions of Node.js you may have installed and which one of those you're currently using:

nvm ls 

List all versions of Node.js available for installation:

nvm ls-remote 

Apparently for Windows the command would be rather like this:

nvm ls available 

Assuming you would pick Node.js v8.1.0 for installation you'd type the following to install that version:

nvm install 8.1.0 

You are then free to choose between installed versions of Node.js. So if you would need to use an older version like v4.2.0 you would set it as the active version like this:

nvm use 4.2 

That should be all.


In 2013 I used the following instructions to upgrade from Node.js version 0.10.6 to 0.10.21 on a Mac, for more recent instructions see above.

Update from 2017: Please mind, Mr. Walsh himself recommended to update Node.js just using nvm instead.

  1. Clear NPM's cache:

     sudo npm cache clean -f 
  2. Install a little helper called 'n'

     sudo npm install -g n 
  3. Install latest stable Node.js version

     sudo n stable 

Alternatively pick a specific version and install like this:

sudo n 0.8.20 

For production environments you might want to pay attention to version numbering and be picky about odd/even numbers.

Credits

Sign up to request clarification or add additional context in comments.

19 Comments

You should credit your source - your answer is quoted from David Walsh's blog: davidwalsh.name/upgrade-nodejs. It should also be noted that this method has major caveats, some rather destructive, as seen in the comments on the original blog post.
Unfortunately that din't worked for me.. was doing exact as described on a Linux machine - 'node -v' before and after showed 'v0.10.5'
One more step. Close and re-open terminal or if using ssh, exit and log back in to see new node-v
Seems to work for me but just followed the link to David Walsh's Blog above and he explicitly says not to use it - be warned!
you should mention that your answer is NOT cross-platform or change it accordingly. Specifically, it is NOT working for WIndows (7, for example), that was several times mentioned other users. Whtn you change it, i will take off my downvote, and may be upvote, if i like it.
|
751

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

Below are the full steps to use NVM for multiple version of node on windows

  1. download nvm-setup.zip extract and install it.
  2. execute command nvm list available from cmd or gitbash or powershell, this will list all available version of node enter image description here
  3. use command nvm install version e.g. nvm install 12.14.0 to install on the machine
  4. last once installed use nvm use version to use newer version e.g. nvm use 12.14.0

14 Comments

FYI, the command to run once having install NVM is 'nvm install <version>'. For example 'nvm install v0.8.7'
You don't need this. Node is not Ruby.
@SimonEast There is an nvm for windows: github.com/coreybutler/nvm-windows
@PhilHannent as per NVM github page, they don't support NVM on windows, so one can say that "there is no official NVM for windows"
For windows just download latest version and install it. It will be automatically updated to new version you downloaded.
|
707

Any OS (including Windows, Mac & Linux)

Updated October 2024


Just go to the official Node.js site (nodejs.org), download and execute the installer program.

It will take care of everything and with a few clicks of 'Next' you'll get the latest Node.js version running on your machine. Since 2020 it's the recommended way to update NodeJS. It's the easiest and least frustrating solution.

Download NodeJS for Windows, buttons

Download NodeJS for Win/Mac/Source Code buttons


Pro tips

  • NodeJS installation includes NPM (Node package manager).

  • To check your NPM version use npm version or node --version.

  • If you prefer CLI, to update NPM use npm install -g npm and then npm install -g node.

    • For more details, see the docs for install command.
  • Keep an eye on NodeJS blog - Vulnerabilities so you don't miss important security releases. Keep your NodeJS up-to-date.

  • Operating systems supported by Node.js:

    • Windows, Linux, MacOS, IBM AIX.
    • For Docker users, here's the official Node.js image.
    • For more information on installing Node.js on a variety of less-common operating systems, see this page (there's even Node for Android!).
  • Troubleshooting for Windows:

    If anyone gets file error 2502/2503 like myself during install, run the .msi via Administrator command prompt with command msiexec /package [node msi]


If my answer is helpful, don't forget to upvote it
(here is the original answer by Anmol Saraf, upvote it too)

16 Comments

So simple and obvious.. I was looking for a shortcut, but this way seems the simplest. node --version to check that it worked.. i had to google that too -- don't check my node version very often.
This didnt work for me. I have an ancient install of 0.10.26. I have been trying to install 6.10.0 LTS, but it seems impossible I can download and install 6.10.0 as many times as I want, the windows 10 machine can only see 0.10.26. In "add remove programs" I only see 6.10.0.
Why exactly would you hyperlink operating systems' wiki pages?
I prefer the CLI :D and I am a windows user. npm install -g npm stable then npm install -g node
As usual in windows a double click is all you need to take care of the update. Can confirm having upgraded multiple times successfully simply by downloading the latest version and installing it.
|
481

If you have Homebrew installed (only for macOS):

$ brew upgrade node 

8 Comments

Agreed, I just run "brew upgrade" every few days and I'm kept up to date with the latest changes for all of my packages
This is a pain because it means having to upgrade xcode which means having to upgrade osx...
Mine says node not installed. Note: I didn't install node with homebrew. Is there something else I should do?
How to install specific version of node using brew ?
I wrote this super early in my career, and since then have had a chance to try a bunch of different techniques. I highly recommend installing n and using that if you can, à la another answer on this thread: stackoverflow.com/a/19584407/392113
|
417

2024: Just go to nodejs.org and use the latest installer.

That's it folks. It used to be more complex and people used different kinds of packages and strategies to manage it. But things have changed for the better.

Works for all platforms (Windows, Mac & Linux).

8 Comments

After Setup re-installation gulp didn't work. Then I called npm rebuild and it was fine again.
This didnt work for me. I have an ancient install of 0.10.26. I have been trying to install 6.10.0 LTS, but it seems impossible I can download and install 6.10.0 as many times as I want, the windows 10 machine can only see 0.10.26. In "add remove programs" I only see 6.10.0. I cant find how to remove or update this old version, or how to install the new version over it. Any ideas?
For the last comment, you can use "where" command to find the executable. For example: "where node.exe". In my system (win10) this gives "C:\Program Files\nodejs\node.exe"
i concur, just go to nodejs.org and download and it will update everything automatically
I tried the other solutions to this question and this one was the easiest and least frustrating.
|
214

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 --version or node -v

6 Comments

Be aware it worked for me under Windows 2016 but node was installed into the directory of the current user: C:\Users\my-current-user\AppData\Roaming\npm\...; it did not update an older installation under C:\Program Files\nodejs nor the path variable. i ended up reinstalling with the msi-installer. that fixed it for me.
This is a terrible idea. Why? Later versions of npm require later version of node. Therefore you can update npm and then it stops working as you need a newer version of node. Thus you are back to the start and now your npm is broken.
its installs 6.8.0 for npm ,but i wants 6.11 for NodeJS, is it fine to use npm install -g npm
After this we need to change symlink ln -sf /usr/local/n/versions/node/10.17.0/bin/node /usr/bin/node
As with @surfmuggle the above method wrongly installed node into C:\Users\my-current-user\AppData\Roaming\npm. To fix: I deleted that directory (npm) and removed it from my Windows Path. Then the command node -v would work to pickup the right node version installed from nodejs.org/en/download.
|
154

On Windows you can use Chocolatey to install and update Node.js (and lots of other packages).

Install Node

cinst nodejs.install 

Update Node

cup nodejs.install 

Note: You will need to install Chocolatey before you can use cinst and cup.

6 Comments

I was getting: The schema version of 'Microsoft.AspNet.Mvc' is incompatible with version 2.1.31022.9038 of NuGet. Please upgrade NuGet to the latest version from go.microsoft.com/fwlink/?LinkId=213942. When I tried to run the cup nodejs.install. Found that if I run nuget.exe update -self on the nuget.exe in the C:\Chocolatey\chocolateyinstall directory. Hope this helps anyone out there.
cinst nodejs.install Chocolatey (v0.9.8.27) is installing 'nodejs.install' and dependencies. By installing you accept the license for 'nodejs.install' and each dependency you are installing. Unable to find package 'nodejs.install'. Command 'install' failed (sometimes this indicates a partial failure). Additional info/packages: nodejs.install
I feel a question about how you update Chocolatey coming on.
What's the difference between nodejs.install and nodejs?
@OhadSchneider if you use .install then you will be able to uninstall node from "Apps & features" in windows
|
112

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 

For the latest LTS version(Tested on Mac)

sudo n lts 

4 Comments

Could you not do this in 2011? Why did everybody else answer with external solutions? +1 for using NPM and deserves answer IMO.
Worked for me on an AWS EC2 Linux instance
If you are trying to install "n" on windows, do not waste your time. At this time, still, "n" does not run on windows. For windows you either have to update from the installers on nodejs.org, use npm `npm install -g node``, use chocolaty, or install nvm (a third party version manager for node).
@ErikReppen n is a node package. This counts as "external" for me.
92

To control your version of Node.js, you can try n. I found it very straightforward and useful.

n is a Node.js binary management, no subshells, no profile setup, no convoluted API, just simple.

npm install -g n 

n 0.6.19 will install Node.js v0.6.19.

11 Comments

Also you can switch between different nodejs versions, just type "n" and select version you need
I couldn't get it to work on Windows either. The author should publish that fact. It was a dead end for me.
It works for me in Windows within the git bash shell. So if you use git fire up git bash and try it there!
Doesn't work on Win7 for me - even in git bash. npm ERR! notsup Not compatible with your operating system or architecture: [email protected] npm ERR! notsup Valid OS: !win32 npm ERR! notsup Valid Arch: any npm ERR! notsup Actual OS: win32
Git bash does not work for me on Windows 10, 64 bit OS
|
63

Short answer:

Go to this page: Download | Node.js

Download the installer for your platform, then install it.

7 Comments

can you run it on ubuntu/LINUX ??
Not only for Windows, also on Mac this is the quickest
The OP have not mentioned anything about the platform, so the MSI answer is valid.
I revised the answer to say "Download the installer for your platform" instead. You're welcome :) @AshishRatan there are Linux binaries on the same page.
@ADTC nvm is the best solution
|
56

I had the same problem, when I saw that my Node.js installation is outdated.

These few lines will handle everything (for Ubuntu):

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

After this node -v will return you the latest available version.

5 Comments

Worked flawlessly on Mac OS X Yosemite too.
after doing this node -v still returned an older version number. But using whereis node I could actually detect that a recent version was installed in /usr/local/bin/node
Worked without any hassle on Ubuntu 18.04.
@bvbd the version of node that is used (by default) in this case likely depends on the order of directories in your PATH
@bvdb If "node -v" shows the old version you should start a new terminal
23

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.

6 Comments

worked for me, important thing that I missed before was a symbolic linking.
Note that EPEL7 as of now has the latest long term stable version, so these steps are only recommended if you want something newer.
node –v module.js:473 throw err; ^ Error: Cannot find module '/root/test/–v'
n latest /usr/bin/n: line 263: which: command not found /usr/bin/n: line 263: which: command not found
@AlexeySh. It worked for me and apparently at least 16 other people.
|
13

For OS X, I had v5.4.1 and needed the latest version 6 so I went to the Node.js homepage and clicked on one of the links below:

Node.js OS X download links

I then followed the installer and then I magically had the latest version of Node.js and npm.

Comments

9

You may use nvm.

  1. Check what is the latest version at http://nodejs.org/ (e.g. v0.10.26)
  2. Run nvm install v0.10.26

Done.

You can choose which version to run:

nvm ls list the available versions and tells you which version you are using now.

nvm use VERSION change the current node to the requested version.

nvm alias default VERSION set the default version. The next time you source nvm.sh, this will be the version loaded (note that it doesn't change the version in use right now, run nvm use for that).

4 Comments

nvm is third party library :P
This is embarrassing. I used it since day one and didn't notice. I'll edit the answer.
nvm alias default VERSION was my savior!
I would also add nvm copy-packages <previous version> to update all global dependencies at the end
9

For macOS in 2018+ (as ALL of the solutions above are failing for me):

Simply go to the official nodejs site, download the official nodejs package and install it by double clicking. It's the most simple, safe and always-working thing you can do.

Comments

8

Some Linux distributions such as Arch Linux have Node.js in their package repositories. On such systems it is better to use a standard package update procedure, such as pacman -Suy or analogous apt-get or yum commands.

As of now (Nov 2016) EPEL7 offers a pretty recent version of Node.js (6.9.1 which is an up-to-date LTS version offered on the Node.js home page). So on CentOS 7 and derivatives you can just add EPEL repository by yum install epel-release and yum install nodejs.

CentOS 6/EPEL6 has 0.10.x which isn't supported upstream since Oct 2016.

Comments

7

Today I ran on a Windows Git Bash:

$ npm i node -g 

and got the following output:

> [email protected] preinstall C:\Users\X\AppData\Roaming\npm\node_modules\node > node installArchSpecificPackage + [email protected] added 1 package and audited 1 package in 23.368s found 0 vulnerabilities C:\Users\X\AppData\Roaming\npm\node -> C:\Users\X\AppData\Roaming\npm\node_modules\node\bin\node + [email protected] added 2 packages from 1 contributor in 26.089s 

Read more about it at https://www.npmjs.com/package/node.

1 Comment

Same here. Out of nowhere my nodejs is deinstalled
6

The easy way to update node and npm :

npm install -g npm@latest 

download the latest version of node js and update /install

1 Comment

you can drop the @latest part, it's the default behavior for npm.
5

For Ubuntu:

sudo apt-get install -y curl curl -sL https://deb.nodesource.com/setup_0.12 | sudo bash - sudo apt-get install -y nodejs 

Source: https://askubuntu.com/questions/426750/how-can-i-update-my-nodejs-to-the-latest-version

3 Comments

curl {anything} | sudo bash - can't possibly be a good security practice... Even leaving sophisticated attacks aside, what if you misspell the domain name?
Your comment adds no value to the answer. You can also misspell your bank domain and leak your bank details in a fake bank website.
Do not do npm i n -g afterwards to update node, because then you get two nodes on your system. Stay with this update process of apt. Alternatively you can try snap which also has a built-in update function
5
$ npm install -g npm stable 

worked for me to update npm

1 Comment

This is to update npm and the question is for updating nodejs
5

2 Comments

NB: This will copy nvm.sh to your home directory. You should then run source ~/.nvm/nvm.sh to set up the nvm command. Now you you can run nvm ls, etc as listed above. This is only necessary if you do not want to have to re-open your terminal, e.g. if you are SSH'd into a remote server.
there is Apache Cordova fetchable as its subdependencies also there.
4

You may use Chocolatey on Windows. It's very easy to use and useful for keeping you updated with other applications too.

Also, you can just simply download the latest version from https://nodejs.org and install it.

1 Comment

He asked "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)." and I suggested him to use Chocolatey to simplify the process but I also suggested him to download the latest version from the site and install it, wich is more than enough to update the nodeJS as he asked. So, I think my answer does provide a satisfactory solution for his question.
4

According to Nodejs Official Page, you can install&update new node version on windows using Chocolatey or Scoop

Using(Chocolatey):

cinst nodejs # or for full install with npm cinst nodejs.install 

Using(Scoop):

scoop install nodejs 

Also you can download the Windows Installer directly from the nodejs.org web site

Comments

3

As some of you already said, the easiest way is to update Node.js through the Node.js package manager, npm. If you are a Linux (Debian-based in my case) user I would suggest to add these lines to your .bashrc file (in home directory):

function nodejsupdate() { ARGC=$# version=latest if [ $ARGC != 0 ]; then version=$1 fi sudo npm cache clean -f sudo npm install -g n sudo n $version } 

Restart your terminal after saving and write nodejsupdate to update to the latest version of Node.js or nodejsupdate v6.0.0 (for example) to update to a specific version of Node.js.

BONUS: Update npm (add these lines to .bashrc)

function npmupdate() { sudo npm i npm -g } 

After restarting the terminal write npmupdate to update your node package manager to the latest version.

Now you can update Node.js and npm through your terminal (easier).

Comments

3

In windows download the node executable file from the website and install it. this worked for me.

Comments

1

All you need to version update of Node.js:

$ brew install node 

If you don't have Homebrew; please go http://brew.sh/.

3 Comments

Homebrew doesn't work on all platforms that Node.js does.
Homebrew won't update a version of Node.js installed through some other means either. It will install parallel to it.
brew upgrade node
0

Just install the new version over the current folder. I upgraded mine from v4.x to v6.10 on Windows.

Comments

-3
  1. npm clean cache - you forget to clean ur cache

  2. npm update -g

    This works on mine Windows, I hope it will also work for you :D

2 Comments

npm cache clean (a different order)
npm update -g command updates all globally installed packages, but not node.js itself.
-5

If you want to update Node.js, just try

npm update 

from your Windows cmd prompt.

Else if you want to update any specific package try

npm update <package_name> 

Example:

npm update phonegap 

3 Comments

That's a great answer for a different question.
This does not work for me. Before doing nmp update, node --version says 0.10.26. After doing update, same version. Even though the latest version is 7.7.1 or similar.
This didn't work for me either.
-10

open cmd and type

npm i -g npm 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.