Mac Use multiple NMP versions by NVM

Hello programmers, how you all are doing great! today I will explain the most popular way to use multiple NPM versions.

  1. Remove exists NPM version from your mac.
1
2
brew uninstall --ignore-dependencies node
brew uninstall --force node

2. Install NVM on your Mac

1
2
brew update
brew install nvm

3. For NVP create a directory

1
mkdir ~/.nvm

4. Edit the following configuration file in your home directory to configure the required environment variables.

1
2
vim ~/.bash_profile # For older version
nano ~/.zshrc # macOS Catalina or later

5. Add the below code to ~/.bash_profile ( or ~/.zshrc for macOS Catalina or later)

1
2
export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh

6. Restart terminal

7. See all available NPM versions

1
nvm ls-remote

8. Install Node.js with NVM

1
2
nvm install node # Installing Latest version
nvm install 14   # Installing Node.js 14.X version

9. Check which version you are using

1
nvm ls

10. Switch to another NPM version

1
nvm use 14

Set default node version

1
nvm alias default 14

Enjoy it, Learned from here

Happy coding 🙂