How do I update Node.js?

node.jsSoftware Update

node.js Problem Overview


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

node.js Solutions


Solution 1 - node.js

I used the following instructions to upgrade from Node.js version 0.10.6 to 0.10.21 on a Mac.

  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


Update (June 2017):

This four years old post still receives up-votes so I'm guessing it still works for many people. However, Mr. Walsh himself recommended to update Node.js just using nvm instead.

So here's what you might want to do today:

Find out which version of Node.js you are 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

Solution 2 - node.js

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

Solution 3 - node.js

Any OS (including Windows, Mac & Linux)

Updated May 2021


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:

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

Solution 4 - node.js

If you have Homebrew installed (only for macOS):

$ brew upgrade node

Solution 5 - node.js

2021: Just go to [nodejs.org][1] 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).

[1]: https://nodejs.org/en/ "nodejs.org"

Solution 6 - node.js

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

Solution 7 - node.js

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.

Solution 8 - node.js

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

Solution 9 - node.js

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.

Solution 10 - node.js

Short answer:

Go to this page: Download | Node.js

Download the installer for your platform, then install it.

Solution 11 - node.js

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.

Solution 12 - node.js

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.

Solution 13 - node.js

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.

Solution 14 - node.js

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

Solution 15 - node.js

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.

Solution 16 - node.js

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.

Solution 17 - node.js

The easy way to update node and npm :

npm install -g npm@latest

download the latest version of node js and update /install

Solution 18 - node.js

Today I ran on a Windows Git Bash:

$ npm i node -g

and got the following output:

> node@10.6.0 preinstall C:\Users\X\AppData\Roaming\npm\node_modules\node
> node installArchSpecificPackage

+ node-win-x64@10.6.0
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
+ node@10.6.0
added 2 packages from 1 contributor in 26.089s

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

Solution 19 - node.js

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.

Solution 20 - node.js

$ npm install -g npm stable

worked for me to update npm

Solution 21 - node.js

Solution 22 - node.js

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

Solution 23 - node.js

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

Solution 24 - node.js

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

Solution 25 - node.js

All you need to version update of Node.js:

$ brew install node

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

Solution 26 - node.js

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

Solution 27 - node.js

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

Solution 28 - node.js

  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

Solution 29 - node.js

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

Solution 30 - node.js

open cmd and type

npm i -g npm

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionalexchencoView Question on Stackoverflow
Solution 1 - node.jsOliver SchafeldView Answer on Stackoverflow
Solution 2 - node.jspradeekView Answer on Stackoverflow
Solution 3 - node.jsnaXa stands with UkraineView Answer on Stackoverflow
Solution 4 - node.jsWillView Answer on Stackoverflow
Solution 5 - node.jssweletView Answer on Stackoverflow
Solution 6 - node.jsAndreView Answer on Stackoverflow
Solution 7 - node.jsrobView Answer on Stackoverflow
Solution 8 - node.jsuser1429844View Answer on Stackoverflow
Solution 9 - node.jsClément RenaudView Answer on Stackoverflow
Solution 10 - node.jshaotangView Answer on Stackoverflow
Solution 11 - node.jsSalvador DaliView Answer on Stackoverflow
Solution 12 - node.jscrmpiccoView Answer on Stackoverflow
Solution 13 - node.jsiamyojimboView Answer on Stackoverflow
Solution 14 - node.jsRiccardo GalliView Answer on Stackoverflow
Solution 15 - node.jsSliqView Answer on Stackoverflow
Solution 16 - node.jsnponeccopView Answer on Stackoverflow
Solution 17 - node.jsmekala goutham budda devView Answer on Stackoverflow
Solution 18 - node.jsFuhrmanatorView Answer on Stackoverflow
Solution 19 - node.jsAndre MorataView Answer on Stackoverflow
Solution 20 - node.jsKarthigaView Answer on Stackoverflow
Solution 21 - node.jsFaisal HassanView Answer on Stackoverflow
Solution 22 - node.jsBruno PaulinoView Answer on Stackoverflow
Solution 23 - node.jsMostafaView Answer on Stackoverflow
Solution 24 - node.jsAlFraView Answer on Stackoverflow
Solution 25 - node.jssuperdemView Answer on Stackoverflow
Solution 26 - node.jsKelvin YeoView Answer on Stackoverflow
Solution 27 - node.jstfaView Answer on Stackoverflow
Solution 28 - node.jsRaman AggarwalView Answer on Stackoverflow
Solution 29 - node.jsAmol GhotankarView Answer on Stackoverflow
Solution 30 - node.jsRubin LuitelView Answer on Stackoverflow