brew install node
sudo apt-get install nodejs npm
Go to http://nodejs.org and click install, then follow the instructions.
Using Node.js version manager n
Download n from the following url
https://github.com/visionmedia/n/archive/master.zip
Suggestion, use curl or simply git clone it.
# OSX
brew install curl
# Ubuntu
sudo apt-get update
sudo apt-get install curl
curl -o master.zip https://codeload.github.com/visionmedia/n/zip/master
# Install unzip if needed like curl
unzip master.zip
# OSX
xcode-select --install
# Ubuntu
sudo apt-get install build-essential
cd n-master
mkdir $HOME/bin
PREFIX=$HOME make install
export N_PREFIX=$HOME
export PATH=$HOME/bin:$PATH
# Save them
echo 'export N_PREFIX=$HOME' >> ~/.profile
echo 'export PATH=$HOME/bin:$PATH' >> ~/.profile
n stable