Install nvm and node.js on OS X

Here are the steps to install nvm and node.js on OS X. I’m using a MacBook Pro with Yosemite.

Install Script

Open an Terminal window and download the install script with the curl command.

curl https://raw.githubusercontent.com/creationix/nvm/v0.19.0/install.sh | bash

nvm is shell script, which needs to be sourced in order to be available. To have it sourced in every terminal you open, put the following line in.bash_profile:

. ~/.nvm/nvm.sh

Close and re-open your terminal or source the nvm.sh script for the changes to take effect.

Install Node

You can find the latest version of node on theĀ node.js download or you can install the latest stable release with the command:

nvm install stable

Install Node Packages

Let’s install some node packages to make sure everything is working correctly:

npm install -g bower
npm install -g grunt-cli
npm install -g grunt
npm install -g yo
npm install -g rgstephens/generator-mobile

Displaying Global Packages

We installed the packages with the -g option so that they will be available to all node projects. To list the installed global packages you can use the following commands:

npm list -g
npm list -g --depth=0

Useful Posts

There were a couple of very useful posts on this topic. Jared Hanson has a 2011 post on this topic and there’s an excellent response on Stackoverflow by Dominic Trancredi on how to perform a complete removal of node.

Leave a Reply

Your email address will not be published. Required fields are marked *