Current Size:
Chakra BreakPoints
base0px
sm480px
md768px
lg992px
xl1280px
2xl1536px
Current Height:Width
widthpx
heightpx

Solution for Managing Multiple Versions of Node on MacOS

#solution #env

This article goes over solutions for managing multiple versions of Node.js on macOS. We'll start with a solution that I felt was straightforward and easily manageable. This is a living article and other solutions may be added over time. This solution was pulled from

How to manage multiple Node.js versions on macOS X - Notiz.dev
and this article is meant as a public personal reference.

Assumptions

  • HomeBrew is installed
  • general understanding of bash/zsh profiles

Install Desired Node Versions

brew install node@<version>

Example

brew install node@16

The default brew install node installed the latest version

Useful CLI commands to check work

Check node version

node --version

Check node install location

which node

Use Alsias to switch Node versions

Add and alias to .zshrc for each Node version installed.

Copy the following to .zshrc

alias node16='export PATH="/usr/local/opt/node@16/bin:$PATH"'
alias node14='export PATH="/usr/local/opt/node@14/bin:$PATH"'

or from terminal

echo -n alias node13='export PATH="/usr/local/opt/node@16/bin:$PATH"' >> ~/.zshrc
echo -n alias node13='export PATH="/usr/local/opt/node@14/bin:$PATH"' >> ~/.zshrc

Refernece alias in CLI to switch between node versions

Example

node16
node -v # v16.11.0

📔 This solution only changes the Node version in the terminal instance

More /Articles

All Articles
HomeProjects

Links

Home Articles Notes Projects About Style Guide Site Credits

Contact

 [email protected]

Location

🌎 Earth