Here are the steps to install nvm and node.js on OS X. I'm using a MacBook Pro with Yosemite.
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.
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
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
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
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.