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!

Installing a specific version of Cordova

With the recent releases and compatibility issues with the plugins we have to switch to some particular version of Cordova/Phonegap which works stable for our exisiting projects. However I was having issue in finding the exact version no to which I need to re-install.

Using command line we can see the versions of cordova available by

npm view cordova versions

The output is like :

C:\Users\upasana>npm view cordova versions

[ '0.0.0-fake',
'0.0.1',
'0.0.2',
'0.0.3',
'0.0.4',
'0.0.5',
'0.0.6',
'0.0.7',
'0.0.8',
'0.0.9',
'0.1.0',
..............
..............
'4.0.0',
'4.0.1',
'4.1.0',
'4.1.1',
'4.1.2',
'4.1.3-nightly.2014.10.21',
'4.2.0',
'4.3.0',
'4.3.1',
'5.0.0',
'5.1.1' ]

 

Then to install a particular version we use the following command.

npm install -g cordova@4.2.0

Have a great day!