By W.ZH Oct 2016
Install latest Node.js, from Node.js website:
First, make sure you have a C++ compiler. Open the terminal and install the build-essential and libssl-dev packages if needed. By default, Ubuntu does not come with these tools — but they can be installed in the command line.
Use apt-get to install the build-essential package and libssl-dev:
sudo apt-get install build-essential checkinstall sudo apt-get install libssl-dev
You can install and update Node Version Manager, or nvm, by using cURL:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh | bash
You will be asked to close and reopen the terminal. To verify that nvm has been successfully installed after you reopen the terminal, use:
command -v nvm
That command will output nvm if the installation worked.
To download, compile and install the latest version of Node:
nvm use 6.0
nvm alias default node
Install latest NPM
There’s a pretty robust install script at https://www.npmjs.org/install.sh. You can download that and run it.
Here’s an example using curl:
curl -L https://npmjs.org/install.sh | sh