Categories
linux node-modules node.js npm npm-update

How can I update NodeJS and NPM to their latest versions?

1987

I just installed Node.js & NPM (Node Package Manager)

I installed NPM for access to additional Node.js Modules.

After I installed Node.js & NPM I noticed that neither were the latest versions available.

I would like to know: How do I upgrade Node.js, NPM, and my Node.js Modules to their latest versions?

Do I need to uninstall Node.js & NPM and reinstall the latest versions?

Here is the link to what I have tried so far. This link is a section from npm.

9

491

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.


EDIT: Please don’t use n anymore. I recommend using nvm. You can simply install stable by following the commands below:

nvm ls-remote
nvm install <version> 
nvm use <version>

14

  • 11

    Refuses to run for windows x64 (but does with win32 apparently). That’s not in keeping with the Node.js project.

    – rainabba

    Jan 29, 2015 at 0:10

  • 10

    Not supported for Windows. I realize it would be easier to just use Linux, but at work, I am not free to choose my OS. As @rainabba says, the spirit of the Node.js project is to be cross-platform, and this isn’t.

    Nov 5, 2015 at 19:04


  • 2

    In Windows, you can simply download the newest version of node and install it. It’ll upgrade both node and npm.

    Dec 17, 2015 at 22:13

  • 23

    Why did you said ‘Please don’t use n anymore’ ? Any particular reason ?

    – Qiulang

    Jan 16, 2019 at 4:59

  • 6

    I do not know why David Walsh said n was unstable at the time, but that blog was from six years ago and n is still being maintained. Repeating other commenters, n does not run on Windows. And neither does nvm.

    Feb 16, 2019 at 22:57

403

Updating npm is easy:

npm install [email protected] -g

8