How to install / upgrade Node.js via command line

The server side JavaScript software system, Node.js, has just been updated to version 0.8.17 which fixes integer overflow vulnerability in TypedArrays. The new update also comes with better performance and npm peerDependencies. If you use TypedArrays, it is highly recommended to upgrade Node.js to v0.8.17.

If you are a new Node.js developer, you may need to know how to upgrade the Node.js software via command line. In this post I will show you how to install or upgrade Node.js to the latest version using NVM (node version manager) which is the best way to manage your Node.js versioning/upgrading. I assume you have ‘git’ installed in your system. Follow the steps below to upgrade Node.js!

$ git clone git://github.com/creationix/nvm.git ~/nvm
Cloning into '/Users/fuad/nvm'...
remote: Counting objects: 518, done.
remote: Compressing objects: 100% (298/298), done.
remote: Total 518 (delta 268), reused 444 (delta 209)
Receiving objects: 100% (518/518), 71.33 KiB | 32 KiB/s, done.
Resolving deltas: 100% (268/268), done.

Activate the nvm by running the command below from your $HOME directory

$ . ~/nvm/nvm.sh 

Download, compile, and install the latest version of Node.js (version 0.8.17 at the time of this writing).

$ nvm install v0.8.17
######################################################################## 100.0%
Now using node v0.8.17

Verify the node version

$ node -v
v0.8.17

Done. I have tested it works on OS X 10.8 Mountain Lion.
Reference https://github.com/creationix/nvm