How to manage multiple Node.js versions on macOS X

How to manage multiple Node.js versions on macOS X using homebrew.

Authors
Marc Stammerjohann Marc Stammerjohann
Published at

Here is a quick tip on how to install multiple Node.js versions (10, 12, 13 etc.) on macOS X and how to switch between them for your applications.

Installing Node via Homebrew

Install multiple Node versions using Homebrew. To install Homebrew run:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

Now install the Node versions you need using brew:

brew install node@<version>

# latest version
brew install node

# LTS 12
brew install node@12

# 10
brew install node@10

To check the default node version and installation path:

node -v # v13.11.0
which node # /usr/local/bin/node => /usr/local/opt/node@<version>/bin/node

Switch Node via alias

Add an alias to your .zshrc or .bash_profile for each installed Node version. Node is installed at /usr/local/opt/node@<version>/bin

alias node13='export PATH="/usr/local/opt/node@13/bin:$PATH"'
alias node12='export PATH="/usr/local/opt/node@12/bin:$PATH"'
alias node10='export PATH="/usr/local/opt/node@10/bin:$PATH"'

Now, to switch between the node versions, enter an alias node10 in your terminal. Execute node -v to verify that you are now using the correct node version.

Alias **only** changes the Node version in the used terminal instance

Sponsor us

Did you find this post useful? We at notiz.dev write about our experiences developing Apps, Websites and APIs and develop Open Source tools. Your support would mean a lot to us 🙏. Receive a reward by sponsoring us on Patreon or start with a one-time donation on GitHub Sponsors.

Table of Contents

Top of Page Comments Related Articles

Related Posts

Find more posts like this one.

Authors
Gary Großgarten
June 08, 2020

Create Keyboard Shortcuts with RxJS

The cleanest way to create and orchestrate Keyboard Shortcuts with RxJS.
RxJS Quick Tip Read More
Authors
Marc Stammerjohann
April 26, 2020

Migrate Git Repository to Git Large File Storage (LFS)

How to migrate an existing Git Repository to use Git Large File Storage (LFS).
Quick Tip Git Read More
Authors
Marc Stammerjohann
October 23, 2020

How to manage multiple Java JDK versions on macOS X

How to manage multiple Java JDK versions on macOS X using homebrew.
Quick Tip Java Read More

more coming soon

Get in Touch!

Sign up for our newsletter

Sign up for our newsletter to stay up to date. Sent every other week.

We care about the protection of your data. Read our Privacy Policy.