Run multiple NodeJS versions with Node Version Manager (NVM) — for MacOS

If you use Node.js for your applications, you may want to use different versions of Node. Fortunately, there is a tool to manage them all using Node Version Manager.


Node.js is an open source JavaScript run-time environment used for making web servers and other networking tools.

Node.js uses an event-driven, non-blocking I/O model unlike other server-side platforms e.g. PHP whereby functions tend to block until completion, which means that commands execute one at a time. In, Node.js, commands are executed in parallel, and callbacks are used to determine completion or failure.

Node.js Version Updates

A new release of Node.js is cut from the GitHub master branch every six months. Whenever a new odd-numbered version comes out, the most recent even version goes to long-term support, or LTS. Versions under LTS receive active support for 18 months followed by an additional 12 months of maintenance support.

What is Node Version Manager (NVM)?

Node Version Manager is a tool that allows programmers to seamlessly switch between different versions of Node. With NVM, you can easily switch and install each Node version with a simple command line interface command. In addition, you can also set a default version for use.

When you are faced with bugs, using a version manager makes it simple to switch node versions for quick troubleshooting. Otherwise, it would be tedious and time-consuming to have to uninstall and reinstall node versions and their global packages.

Installing NVM for MacOS

Install Node Version Manager using either cURL or Wget.

For cURL, run the following from your terminal:

curl -o- | bash

The above commands will clone the repository to ~/.nvm and apply changes to your bash profile and that allows you to access NVM from your terminal.

Using cURL to install NVM

We can then run these 3 lines in the terminal in order to use NVM right away:

export NVM_DIR="$HOME/.nvm"[ -s "$NVM_DIR/" ] && \. "$NVM_DIR/"  
# This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
Run the above 3 lines in the terminal in order to use NVM right away

And these are what you can use with NVM:

nvm CLI usage instructions


A useful command is default alias. To use the latest version of Node.js as default, run:nvm alias default node

You are also able to name your own aliases using the following format:

nvm alias side-project 10.13.0

The above command creates an alias called ‘side-project’ for version 10.13.0. To use this version, you can use it like so:

nvm use side-project

If you want to removethis alias, just run:

nvm unalias side-project

To view the list of Node.js versions on your computer, run:

nvm ls

The version which is being currently used will appear in green and have an arrow pointing to it.

nvm current


$ nvm current
// v10.13.0

Software Developer at @thoughtworks | Marathon Runner | Ex-Pharmacist Writing on Coding, Technology and Running

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store