To install nvm (Node Version Manager) on a Mac, you can follow these steps:
Install Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Install nvm:
brew install nvm
Add the following line to your .bash_profile or .zshrc file:
export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
Reload your shell:
source ~/.bash_profile # or source ~/.zshrc
Verify the installation by checking the version:
nvm --version
Don’t Miss : how to install nvm on ubuntu?
Now you can install and switch between different Node.js versions using nvm.