Updating Node JS from NPM

Normally, you would have to visit the Node JS website to download an updated version of Node. This can be a bit slow and a pain. Why can’t Node JS update itself if you want it to? Well here’s a stop-gap solution for now, updating using NPM itself. NPM has a packaged called ‘n’ which can be invoked to update Node to one of the various release streams (I recommend the stable release), and this is how you use it:

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

These commands clean the npm cache, install the NPM module ‘n’ which is a node helper, and then invokes ‘n’ to install the latest stable version of Node. Additionally you can choose which version to install with a command like this:

sudo n 0.9.1

Making it much easier and quicker than visiting the website.

Source: DavidWalsh.name
Original: The Holmes Office