Update Node.js on Mac OS

Well for quite sometime I was using Node v 0.12x on my system, whereas nodejs has been updated to 7.x till date
I thought I used the right commands but the updates were never reflected

Gladly, I found this article on web.

I am writing down the steps that worked for me (it seems XAMPP on mac adds on some steps to the installation procedure) :

A simple way to upgrade Node.js from the Terminal is to use the n version manager:

1 npm install -g n
2 npm cache clean -f

Now, if you have XAMPP installed on your Mac, you need to do an extra step before upgrading Node.js:

1 cd /Applications/XAMPP/xamppfiles/bin
2 sudo mv HEAD _HEAD

At this point upgrading Node.js is as simple as:

1 sudo n stable
2 npm update -g

For XAMPP users only, rename _HEAD back to the original HEAD:

1 cd /Applications/XAMPP/xamppfiles/bin
2 sudo mv _HEAD HEAD

You can check which versions of npm and Node.js you have on your system with:

1 node -v
2 npm -v

Cheers!