Logo
← Back to Blog

Install NVM in macOS

Node.js

Published on April 15, 2022

Install NVM

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

Install Node.js versions in NVM

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

Switch between node.js versions in NVM

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