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.
brew uninstall --ignore-dependencies node 
brew uninstall --force node 

2. Install NVM on your Mac

brew update
brew install nvm

3. For NVP create a directory

mkdir ~/.nvm

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

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)

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

6. Restart terminal

7. See all available NPM versions

nvm ls-remote

8. Install Node.js with NVM

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

9. Check which version you are using

nvm ls

10. Switch to another NPM version

nvm use 14

Set default node version

nvm alias default 14

Enjoy it, Learned from here

Happy coding 🙂