A Quick Guide to Setting Up NVM on MacOS

Version control is important when working with software. Unfortunately, the biggest bane is shipping products despite compatibility issues and breaking changes. Sometimes your code breaks if you use newer versions of node or if your node version is outdated.
Managing all the versions can be a hassle but that’s where NVM shines. It allows you to easily toggle versions of node with ease depending on a project's fit.
Let’s dive In!
Step 1: Install Brew
Ensure that you have brew installed. Brew is MacOs’s most popular package installer.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Step 2: Install NVM
brew install nvm
To make nvm available across your terminal you have to source it.
source $(brew --prefix nvm)/nvm.sh
Step 3: Install Node
Next thing install node using nvm.
nvm install node
Step 3: Using NVM
Using NVM is pretty straightforward. Remember that, nvm makes it easy to use different versions of node with easy without having conflicts.
- First you have to install the node version you need depending on the version number e.g 18 means node version 18, 20 means node version 20, etc
nvm install 18
nvm install 20
nvm install 16
- After installing you need to be able to utilize these versions anytime from your terminal using the command “use”
nvm use 18
viola! you can now use nvm with ease and switch versions at will. That’s some Thanos stunt!