My programming ramblings

How to upgrade Node.js on Mac OS X

Posted on April 29, 2016 by Paul

If you already have Node.js installed on your Mac you will need to upgrade it when a new version comes up. There are basically two ways to achieve this goal download the installer from Node.js or use the command line to upgrade Node.js.

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

1 npm install -g n2 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/bin2 sudo mv HEAD _HEAD

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

1 sudo n stable2 npm update -g

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

1 cd /Applications/XAMPP/xamppfiles/bin2 sudo mv _HEAD HEAD

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

Disclaimer:All data and information provided on this site is for informational purposes only. solarianprogrammer.com makes no representations as to accuracy, completeness, currentness, suitability, or validity of any information on this site and will not be liable for any errors, omissions, or delays in this information or any losses, injuries, or damages arising from its display or use. All information is provided on an as-is basis. solarianprogrammer.com does not collect any personal information about its visitors except that which they provide voluntarily when leaving comments. This information will never be disclosed to any third party for any purpose. Some of the links contained within this site have my referral id, which provides me with a small commission for each sale. Thank you for understanding.