How to update npm

how to update npm-windows
update npm ubuntu
npm update command
npm update node
npm update to specific version
update npm mac
nvm update npm
npm update specific package

I'm trying to install mean.io boilerplate. It fails when running sudo npm install -g meanio@latest. Prior to failing it notes that it 'wants' npm version 1.4.x, whereas I have 1.2.18 installed. So I tried updating npm to the latest; several ways. Last of which was...

ubuntu@ip-xxx-xx-xx-xxx:~$ sudo npm install -g npm
/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js
npm@1.4.7 /usr/local/lib/node_modules/npm

ubuntu@ip-xxx-xx-xx-xxx:~$ npm --version
1.2.18

Why is it still showing version 1.2.18, when I just updated to 1.4.7?

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.

Try the latest stable version of npm, You can upgrade to the latest version of npm using: npm install -g npm@latest. Or upgrade to the most recent release: npm install -g npm@next  Another way, which I prefer, is to use the npm-check-updates (ncu) module. This package allows you to easily upgrade your package.json dependencies to the latest versions of modules regardless of any version constraints in those files. Then with the npm install or npm update commands you can upgrade the installed packages.

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

npm-update, Description§. This command will update all the packages listed to the latest version (specified by the tag config), respecting semver. It will also install missing​  Run npm-upgrade <command> --help to see usage help for corresponding command. check is the default command and can be omitted so running npm-upgrade [filter] is the same as npm-upgrade check [filter]. check command. It will find all your outdated deps and will ask to updated their versions in package.json, one by one.

Looks like you are using Ubuntu (from the command line you show). To update npm and nodejs you can use the PPA repository:

sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs npm

npm-upgrade, npm-upgrade. Interactive CLI utility to easily update outdated NPM dependencies with changelogs inspection support. NPM version  Run npm -v to see which version you have, then npm install npm@latest -g to install the newest npm update. Run npm -v again if you want to make sure npm updated correctly. To update NodeJS , you’ll need npm’s handy n module.

don't forget to close and start the terminal window again ;)

(at least if you want to check "npm --version" in the terminal)

sudo npm install npm -g

that did the trick for me, too

Updating packages downloaded from the registry, To test the update, run the outdated command. There should not be any output. npm outdated. Updating globally-installed packages  npm-windows-upgrade --npm-version latest The tool will show you a list of all the published and available versions of npm (including pre-release and beta versions). Choose the one you want to install and let it do its thing!

Tried the options above on Ubuntu 14.04, but they would constantly produce this error:

npm ERR! tar pack Error reading /root/tmp/npm-15864/1465947804069-0.4854120113886893/package

Then found this solution online:

1) Clean the cache of npm first:

sudo npm cache clean -f

2) Install n module of npm:

sudo npm install -g n

3) Begin the installation by selecting the version of node to install: stable or latest, we will use stable here:

sudo n stable

4) Check the version of node:

node -v

5) Check the version of npm:

npm -v

How to Update Node.js to Latest Version (Linux, Ubuntu, OSX , Run npm -v to see which version you have, then npm install npm@latest -g to install the newest npm update. Run npm -v again if you want to  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.

How to Update npm Packages to their Latest Version, Then with the npm install or npm update commands you can upgrade the installed packages. In the rest of this article, we'll take a look at the  In theory you should be able to do this with npm update npm -g.. Beware that the version of npm bundled with node (1.1.0-alpha-6) is newer than the version you will get with the update command (1.0.106), so you actually downgrade by running update.

Using npm update and npm outdated to update dependencies, It's hard to update a new version of a library. Semantic versioning screws things just enough, so it's safer to manually edit package.json than to attempt npm  Run npm-v to see which version you have, then npm install npm @ latest-g to install the newest npm update. Run npm-v again if you want to make sure npm updated correctly. To update Node, you’ll need npm’s handy n module. Run this code to clear npm’s cache, install n, and install the latest stable version of Node:

How to update all the Node dependencies to their latest version, How do you update all the npm dependencies store in the package.json file, to their latest version available? Instead of npm install, you can use npm update to freshen already installed packages. When you run npm update, npm checks if there exist newer versions in the repository that satisfy specified semantic versioning ranges and installs them. Let's say we depend on lodash version ^3.9.2,

Comments
  • Do sudo npm update npm -g
  • If you can risk the use of an unsupported PPA, try launchpad.net/~chris-lea/+archive/node.js
  • sudo npm install npm -g helped me
  • Possible duplicate of How can I update Node.js and npm to the next versions?
  • This should be on Ask Ubuntu
  • I'd recommend using a PPA repository so you let ubuntu package manager maintain the updates along with everything else.
  • On sort of production servers, yes, maybe. But on dev you really want to guarantee you get stuff directly from the npm package maintainer, not the PPA maintainer
  • I disagree. You don't want dev to be different from production or you will run into deployment issues for different versions.
  • Again depending on how paranoid you are, trusting Chis Lea's PPA might be questionable. There is always a decision possible on how much of the critical dependencies in the project one just offloads as a local copy. If you are not working in the bank but doing an open source project you might not even have a production to worry about :) I will link the node wiki here just listing all the alternatives. Personally I am not a big of PPA vs. github tags when it comes to code distribution.
  • Don't need to use Chris's PPA. Use the official one from node source.
  • user3223763 didn't work for me, neither did self updating npm. Thank you Daniel