How to update npm

This will update npm using npm itself:

sudo npm install npm -g

If you are stuck, try sudo npm update npm -g. All credit goes to Tim Castelijns. I have tested it on ubuntu 14.04, npm 1.3.10


Note that if you are using nvm for managing multiple versions in your local dev environment for e.g. testing purposes, all your installed versions (listed by nvm ls) are in ~/.nvm, hence you just omit system wide installation (i.e. omit sudo):

npm install npm -g

DEBIAN ENTERPRISE

For full enterprise practice consider nodesource.com:

curl -sL https://deb.nodesource.com/setup | sudo bash -

as described here.

OTHER ENTERPRISE

For non-debian distributions check out on the node github wiki https://github.com/joyent/node/wiki/installing-node.js-via-package-manager download page https://nodejs.org/en/download/

For historical understanding: Chis Lea was maintaining his PPA but now joined forces with nodesource.


if user3223763's answer doesn't works, you can try this:

sudo apt-get remove nodejs ^node-* nodejs-*
sudo apt-get autoremove
sudo apt-get clean
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install nodejs

Then :

curl https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | sh

After this, open a new terminal and check the npm version:

npm --version

EDIT / UPDATE :

Today the last nvm version is :

https://raw.githubusercontent.com/creationix/nvm/v0.25.4/install.sh

Thus the CURL command is: v0.25.4 instead of v0.13.1

curl https://raw.githubusercontent.com/creationix/nvm/v0.25.4/install.sh | sh

You can check https://github.com/creationix/nvm/releases to use the correct version for further upgrades