Skip to content

Instantly share code, notes, and snippets.

@MichaelCurrin
Last active June 10, 2021 12:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MichaelCurrin/662f5b5ad93699b112b7de4c10991bda to your computer and use it in GitHub Desktop.
Save MichaelCurrin/662f5b5ad93699b112b7de4c10991bda to your computer and use it in GitHub Desktop.
Install NVM (Node Version Manager)

Install NVM (Node Version Manager)

How to install NVM and install and activate a target Node.js version

You can install multiple version of Node.js using NVM.

Node.js vs NVM

Even for a first-time install of Node.js, you could install Node.js using NVM, as covered in the NVM option on the Node.js install doc. One advantage is that it does not required sudo, which is necessary on macOS when installing Node.js.

To install Node.js alone without NVM, see this gist.

See instructions below from the NVM Install and update docs. See also Install NVM with Homebrew guide.

Install NVM:

  • Use curl. This works on macOS or Linux.
    $ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
  • Use Brew on macOS.
    $ brew install nvm

That will automatically add this code to your .bash_profile or .zshrc file. But you might want move it to a file that is more appropriate for your setup.

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" 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment