If you’re using ubuntu and go the usual way (i.e., sudo apt-get install…) then you’re in for a bad surprise; you’ll get node 0.1x.y and also a very old npm release.
Actually, the best way to get nodejs and npm on Ubuntu is to use the node version manager (nvm).
nvm can be used to install and keep multiple versions of node in parallel, which is very useful, especially when you have to test your node-based project on multiple versions.
The installation is very straightforward:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.29.0/install.sh | bash
After that, close and reopen your terminal. You now have ‘nvm’ at your disposal.
nvm install 4.0 nvm install 5.0 nvm use 5.0
Just with the above, you get two versions of node (along with npm) installed. As you can see, you can use ‘nvm use’ to change the active version easily.