There 3 different ways to install Node.JS on OSX, in this post I will provide instructions on how to do it using Node Version Manager.
Why Node Version Manager (NVM)
Node.JS is a popular framework for the developing applications and has been available since 2009. As with any software development frameworks node is under constant development, with the team making improvements, bug fixes and has undergone it own fair share of forking and merging. This will result in different versions of the software available.
NVM is similar to Ruby’s RVM, allowing you to install and switch between different versions of Node.JS and NPM using the command line. It’s super useful to developers especially if you have to support applications which have been developed utilising different versions of the framework.
Installing Node using NVM on OSX
Node Version Manager (NVM) lets you install multiple versions of Node.js to your local user directory, enabling easy upgrades and version switching, without the permission troubles that are common with non-NVM setups.
If you have previously installed Node on your Macbook, you will need to uninstall. If you have installed node using HomeBrew .Install HomeBrew on Mac
If you have previously installed node using HomeBrew, ensure that you uninstall it before you proceed
brew uninstall --force node
To install NVM, we will need to clone to the Git repository
git clone git://github.com/creationix/nvm.git ~/.nvm
printf "\n\n# NVM\nif [ -s ~/.nvm/nvm.sh ]; then\n\tNVM_DIR=~/.nvm\n\tsource ~/.nvm/nvm.sh\nfi" >> ~/.bashrc
Once complete you can check which version of of nvm has been installed
We can now install any node version we desire.
nvm install 5.7.0
nvm install 5.5.0
nvm install 5.3.0
nvm install 4.2.0
nvm install 0.12
We can now easily switch between different versions of node
nvm use 0.12
We can also check which version of node is currently in use by
We can also check which versions of node are available in your nvm instance by
There are a number of benefits to making use of NVM on your development machine, not only can you host multiple versions of the node framework on your machine but also ensure you no longer require to use sudo to install npm packages – Which is a really good thng when it comes to security of your machine!
A unique background as business owner, marketing, software development and business development ensures that he can offer the optimum business consultancy services across a wide spectrum of business challenges.
Latest posts by Gary Woodfine (see all)
- Happy 4th Blog Birthday – A blogging year in review - Dec 6, 2018
- Getting started with .NET Core and the Serverless Framework - Dec 3, 2018
- How to use the Abstract Factory design pattern in C# - Nov 18, 2018