02 Sep 2017

This article will take about 1 minute to read.

If you are JavaScript developer and not using nvm you might want to look at it. Node Version Manager is easy way to install, manage and work with multiple node versions.

And I recently got npm update notification, that looks like this:

npm update notification

This is image from the internet.

nvm doesn’t let you update only npm, but just a node+npm version. But there is a really easy way to do it:

# navigate to nvm's node lib folder
# (replace v8.4.0 with your version)
cd ~/.nvm/versions/node/v8.4.0/lib/

# update npm right there
npm install npm

# reopen your terminal

That’s it. Great thing is that npm can update itself. And this works for any other global npm package.


Comments (6)

17 Jun 2018, 04:09 PM

Easier way is simply to do an npm global install, which would automatically use the correct path to the current nvm version in use.

npm install -g npm
Shawn Erquhart
23 Oct 2018, 04:25 PM

Turns out nvm does have a command for this (nvm/issues/1541#issuecomment-377826880):

nvm install-latest-npm

Not sure why it isn’t documented.

23 Oct 2018, 04:40 PM

Heh that is awesome, thanks Shawn!

C. L. Jones
14 Dec 2019, 08:47 PM

Nice find, Shawn! Exactly what I needed :).

25 Jan 2020, 06:30 PM

Great tip. Thanks.

Élisson Michael
28 Jan 2020, 06:00 PM

Thank You for Sharing This.

Leave a comment

Sending failed, please try again.
Thank you! Your comment is sent. Please note that all of the comments go through moderation.