# Install NVM

How to Install Command Line Tools in OS X Mavericks & Yosemite (Without Xcode) Note: On OS X, if you have/had a 'system' node installed and want to install modules globally, keep in mind that: When using nvm you do not need sudo to globally install a module with npm -g, so instead of doing sudo npm install -g grunt, do instead npm install -g grunt. NVM is a tool that allows developers to easily switch between different versions of Node. It can be used to install each version with a single command and set a default NodeJs version via the command line itself. NVM is developed mainly for Linux and OS X based systems but it is available for windows also named by NVM Windows.

You can use curl:

Or you can use wget:

# Check NVM version

To verify that nvm has been installed, do:

which should output 'nvm' if the installation was successful.

# Installing an specific Node version

Nvm Osx

Listing available remote versions for installation

Installing a remote version

For example

# Using an already installed node version

To list available local versions of node through NVM:

For example, if nvm ls returns:

You can switch to v5.5.0 with:

Install

# Install nvm on Mac OSX

# INSTALLATION PROCESS

You can install Node Version Manager using git, curl or wget. You run these commands in Terminal on Mac OSX.

curl example:

wget example:

# TEST THAT NVM WAS PROPERLY INSTALLED

To test that nvm was properly installed, close and re-open Terminal and enter nvm. If you get a nvm: command not found message, your OS may not have the necessary .bash_profile file. In Terminal, enter touch ~/.bash_profile and run the above install script again.

If you still get nvm: command not found, try the following:

  • In Terminal, enter nano .bashrc. You should see an export script almost identical to the following:

export NVM_DIR=”/Users/johndoe/.nvm” [ -s “$NVM_DIR/nvm.sh” ] && .“$NVM_DIR/nvm.sh”

  • Copy the export script and remove it from .bashrc
  • Save and Close the .bashrc file (CTRL+O – Enter – CTRL+X)
  • Next, enter nano .bash_profile to open the Bash Profile
  • Paste the export script you copied into the Bash Profile on a new line
  • Save and Close the Bash Profile (CTRL+O – Enter – CTRL+X)
  • Finally enter nano .bashrc to re-open the .bashrc file
  • Paste the following line into the file:

source ~/.nvm/nvm.sh

  • Save and Close (CTRL+O – Enter – CTRL+X)
  • Restart Terminal and enter nvm to test if it's working

# Setting alias for node version

If you want to set some alias name to installed node version, do:

Similary to unalias, do:

A proper usecase would be, if you want to set some other version than stable version as default alias. default aliased versions are loaded on console by default.

Like:

Uninstall Nvm Osx

Then every time console/terminal starts 5.0.1 would be present by default.

Nvm for osx

Note:

Nvm Osx Bashrc

# Run any arbitrary command in a subshell with the desired version of node

List all the node versions installed

Run command using any node installed version

Nvm

To install node LTS version

Version Switching

# Remarks

Nvm Install Osx

The urls used in the above examples reference a specific version of Node Version Manager. It is most likely that the latest version is different to what's being referenced. To install nvm using the latest version, click here to access nvm on GitHub, which will provide you with latest urls.