< FrankJS />

Upgrade Node.js Using npm and n

If you’re looking for how to install Node.js initially, check out my post How to Install Node.js On Linux, Windows, Mac OSX.

This is pretty cool; you can upgrade Node.js with the power of it’s intuitive package manager, npm and the Node.js version manager, n.

You can check your current version of Node by typing:

node -v


Here’s what you need to enter in your terminal:

Optional: Clear your npm cache (this is a “probably not necessary but could be useful” step):

sudo npm cache clean -f

Install ‘n’ (‘n‘ allows you to manage npm versions)

sudo npm install -g n


Install the latest stable version by typing:

sudo n stable

Install a specific version, for example v0.8.11:

sudo n 0.8.11


Bonus tips:

  • npm list -g --depth 0 list global packages

  • npm-check-updates upgrades your package.json dependencies to the latest versions, ignoring specified versions

  • ncu -g ncu is another way to access npm-check-updates, -g checks all your global packages

Frank J Santaguida, 2022