Updating NodeJS via Terminal

In case you would like to update NodeJS via Terminal, here's a way to do so.

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

In short, you're installing globally, and then using n, a NodeJS' helper, to update NodeJS to the latest stable release. If you verify what version of NodeJS is now running on your machine:

node -v

You should get v4.0.0 (latest stable release at today).

Note: The commands works on OSX, and it should work on Linux as well. I am frankly not sure about Windows.