sudo apt-get remove nodejs ^node-* nodejs-*
sudo apt-get autoremove
sudo apt-get clean
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install nodejs
Then :
curl https://raw.githubusercontent.com/creationix/nvm/v0.13.1/install.sh | sh
After this, open a new terminal and check the npm version:
npm --version
http://stackoverflow.com/questions/23393707/how-to-update-npm