I had a problem updating npm after installing new version of node and this solved my problem
Note: If you get "301 Moved Permanently" then try curl -0 -L http://npmjs.org/install.sh | sudo sh to follow redirects. Also notice I added sudo before the sudo sh command depending on your users permissions.

If you want to update stable version of nodejs. n is another nodejs version manager. or you can just go to nodejs.org, download and install it.

##Install module n

$ npm install -g n

$ n stable
We are going to need sudo to do this.

Resources :