Node Version Manager makes it easy to install multiple Node versions on a Mac. You install NVM using Homebrew, and if you don't have Homebrew installed yet, read this article.

Step 0 - Install Homebrew

This short article describes how to install Homebrew or visit the Homebrew website

Step 1: Install NVM

Install node version manager.

brew install nvm


Step 2: Create a directory for NVM

mkdir ~/.nvm/

Step 3: Configure your environmental variables

Either create or open your .bash_profile.

vim ~/.bash_profile

Paste this.

export NVM_DIR="$HOME/.nvm"
source $(brew --prefix nvm)/

Execute the content we just pasted.

source ~/.bash_profile

Step 4: Double-check your work

If you've done everything correctly, you should be able to run the nvm command and ask it to list which versions node are available.

nvm ls


Step 5: Install Node

You can see a list of previously released Node versions from the NodeJS release page

or use search for packages with long-term support --lts.

 nvm ls-remote --lts

Verify your installation.

nvm ls

Step 6: Set Node Globally

You can set a specific version of Node as your default.

nvm alias default x.x.x


Error Example #1

If you are having issues with npm, then you might want to try this.

rm -rf /usr/local/lib/node_modules
brew uninstall --ignore-dependencies node 
brew uninstall --force node 

Install a specific version of Node.

brew install node@14
echo prefix=~/.npm-packages >> ~/.npmrc
curl -L | sh

Add this to your local variables so that npm and global npm are usable.

export PATH="$HOME/.npm-packages/bin:$PATH"


Error Example #2

up to date in 0.027s
sh: rimraf: command not found
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! npm@6.4.1 prepare: `node bin/npm-cli.js --no-audit --no-timing prune --prefix=. --no-global && rimraf test/*/*/node_modules && make -j4 doc`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the npm@6.4.1 prepare script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/myaccount/.npm/_logs/*-debug.log
npm ERR! code E404
npm ERR! 404 Not Found: 0.99s@latest

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/myaccount/.npm/_logs/*-debug.log
It failed

If you see an error like this, then checkout this StackOverflow solution