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
Or you can use
To verify that nvm has been installed, do:
which should output 'nvm' if the installation was successful.
Listing available remote versions for installation
Installing a remote version
To list available local versions of node through NVM:
For example, if
nvm ls returns:
You can switch to
You can install Node Version Manager using git, curl or wget. You run these commands in Terminal on Mac OSX.
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:
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”
nano .bash_profileto open the Bash Profile
nano .bashrcto re-open the .bashrc file
nvmto test if it's working
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.
Then every time console/terminal starts 5.0.1 would be present by default.
List all the node versions installed
Run command using any node installed version
To install node LTS version
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.