Skip to content

Instantly share code, notes, and snippets.

@sandrabosk
Created April 29, 2020 18:44
Show Gist options
  • Save sandrabosk/a9160ca8feb93cbdac6699f2fa37f642 to your computer and use it in GitHub Desktop.
Save sandrabosk/a9160ca8feb93cbdac6699f2fa37f642 to your computer and use it in GitHub Desktop.

[MAC] Install nvm

Remember the Homebrew? In case you missed to install this earlier, please refer to the lesson Mandatory Mac Installations for the prework. We will be using brew command to install the nvm.

nvm is a terminal command that allows you to install and change between different versions of Node.js. Usually, your system can have only one version of Node.js installed at one time. With nvm, you can switch to a newer version, try some new features, and then back to an older version for your more serious projects.

  • Run these commands one by one in your terminal:
$ mkdir ~/.nvm
$ brew install nvm
  • Use your editor to open your terminal settings file (.zshrc or .bash_profile):
$ code ~/$([ -n "$ZSH_VERSION" ] && echo ".zshrc" || echo ".bash_profile")
  • In your editor, copy/paste these lines and save:
export NVM_DIR="$HOME/.nvm"
[ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh"  # This loads nvm
[ -s "/usr/local/opt/nvm/etc/bash_completion" ] && . "/usr/local/opt/nvm/etc/bash_completion"  # This loads nvm bash_completion
  • Close and reopen all your terminal windows.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment