node.js windows - How can I update NodeJS and NPM to the next versions?

latest mac (25)

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.

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.

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

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

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

I followed this steps in the npm section.

I found this really neat way of updating node on David Walsh's blog, you can do it by installing 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.

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

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

sudo apt-get remove nodejs

# assume node.js 8 is latest version
curl -sL | 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.

you should see this blog nodejs install with package-manager

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

Step by Step (Debian):

sudo apt-get update

install 6_x

curl -sL | sudo -E bash -
sudo apt-get install -y nodejs

install 7_x

curl -sL | sudo -E bash -
sudo apt-get install -y nodejs

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:


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

$ brew install node

later you will be able to update it using

$ brew update && brew upgrade node

NPM will be updated as well.

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:

$ ruby -e "$(curl -fsSL"


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

Install Node.js versions easily:

$ 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

• 0.8.17

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.

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:

$ npm install -g n


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

To download, compile, and install the latest v0.10.x release of the Node.js using 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:

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

$ curl | sh

or wget:

$ wget -qO- | sh


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

Just with this code

npm install update

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.

You can also update all outdated local packages by doing npm update without any arguments, or global packages by doing 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:

curl | sh

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

Try the latest stable version of npm

See what version of npm you're running:

npm -v

Upgrading on *nix (OSX, Linux, etc.)

(You may need to prefix these commands with sudo, especially on Linux, or OS X if you installed Node using its default installer.)

You can upgrade to the latest version of npm using:

npm install -g [email protected]

Or upgrade to the most recent release:

npm install -g [email protected]

Upgrading on Windows

By default, npm is installed alongside node in

C:\Program Files (x86)\nodejs

npm's globally installed packages (including, potentially, npm itself) are stored separately in a user-specific directory (which is currently


Because the installer puts

C:\Program Files (x86)\nodejs



on your PATH, it will always use the version of npm installed with node instead of the version of npm you installed using npm -g install [email protected]<version>.

To get around this, you can do one of the following:

  • Option 1: edit your Windows installation's PATH to put %appdata%\npm before %ProgramFiles%\nodejs. Remember that you'll need to restart cmd.exe (and potentially restart Windows) when you make changes to PATH or how npm is installed.

  • Option 2: remove both of

    • %ProgramFiles%\nodejs\npm
    • %ProgramFiles%\nodejs\npm.cmd
  • Option 3: Navigate to %ProgramFiles%\nodejs\node_modules\npm and copy the npmrcfile to another folder or the desktop. Then open cmd.exe and run the following commands:

cd %ProgramFiles%\nodejsnpm install [email protected]

If you installed npm with the node.js installer, after doing one of the previous steps, do the following.

  • Option 1 or 2

    • Go into %ProgramFiles%\nodejs\node_modules\npm and copy the file named npmrc in the new npm folder, which should be %appdata%\npm\node_modules\npm. This will tell the new npm where the global installed packages are.
  • Option 3

    • Copy the npmrc file back into %ProgramFiles%\nodejs\node_modules\npm

A brief note on the built-in Windows configuration

The Node installer installs, directly into the npm folder, a special piece of Windows-specific configuration that tells npm where to install global packages. When npm is used to install itself, it is supposed to copy this special builtin configuration into the new install. There was a bug in some versions of npm that kept this from working, so you may need to go in and fix that up by hand. Run the following command to see where npm will install global packages to verify it is correct.

npm config get prefix -g

If it isn't set to <X>:\Users\<user>\AppData\Roaming\npm, you can run the below command to correct it:

npm config set prefix "${APPDATA}/npm" -g

Incidentally, if you would prefer that packages not be installed to your roaming profile (because you have a quota on your shared network, or it makes logging in or out from a domain sluggish), you can put it in your local app data instead:

npm config set prefix "${LOCALAPPDATA}/npm" -g well as copying %APPDATA%\npm to %LOCALAPPDATA%\npm (and updating your %PATH%, of course).

Everyone who works on npm knows that this process is complicated and fraught, and we're working on making it simpler. Stay tuned.


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

> node -v
> npm -v

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.

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.

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\

> npm -v

Enjoy. :-)

$ npm install -g npm stable

Worked for me to update from 1.4.28 to 2.1.5

First check your NPM version

npm -v

1) Update NPM to current version:

View curent NPM version:

npm view npm version

Update npm to current version:

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)

npm view npm versions --json

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

npm i -g [email protected]
  • Installing one version will automatically remove the one currently installed.

  • For Linux and iOS prepend commands with sudo

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

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>

for nodejs should uninstall it and download your favorite version from for npm run below line in cmd:

npm i npm

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.

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

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

sudo n latest

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

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.

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.

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

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

  • To update your modules, use the npm update command

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:

brew install node --without-npm
echo prefix=~/.npm-packages >> ~/.npmrc
curl -L | sh

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

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

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

cd ~
curl -L | tar xz

Move unpacked package into node_modules folder:

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

Make sure your ~/.bash_profile has following entries:

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

Source the file:

source ~/.bash_profile

Verify installation:

npm -v

For Linux, OSX, etc..

To install the latest version of NPM

npm install -g [email protected]

Or To Install the most recent release

npm install -g [email protected]

Additional : To check your npm version

npm -v

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

Install npm => sudo apt-get install npm

Install n => sudo npm install n -g

latest version of node => sudo n latest

Specific version of node you can

List available node versions => n ls

Install a specific version => sudo n 4.5.0

For Cygwin users:

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

wget -OutFile 'C:\pathto\nodejs\node.exe'
# Updating npm
npm i -g npm

Yes, you need to install wget first.

On Ubuntu you can try this command.

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

Specific version : sudo n 8.11.3 instead of sudo n stable

node.js linux npm node-modules npm-update