Fri Apr 15 2022
How to install NVM and manage Node.js versions in macOS with NVM
Author: Cesar Gomez
Visit the NVM repository and instal via curl or wget
After that you can run the following command to load NVM
export NVM_DIR=»$([ -z «${XDG_CONFIG_HOME-}» ] && printf %s «${HOME}/.nvm» || printf %s «${XDG_CONFIG_HOME}/nvm»)»
[ -s «$NVM_DIR/nvm.sh» ] && \. «$NVM_DIR/nvm.sh» # This loads nvm
Now NVM should be installed, you can double check with:
nvm -v
# this will return the version
To check all node.js versions available you can run:
nvm ls-remote
# this will list all node.js from version 0 to the most recent one
To install a node.js version run the command:
nvm instal node_version
# example nvm install 16.14.2
If you want to check which node.js versions have you already installed, run:
nvm ls
If you want to change between node.js version in NVM run:
nvm use node_version
# example nvm use 16.14.2
You can change your node versions between projects as well, but you should know that switching between node versions will affect your npm versions as well