npm breaks after updating nodejs to 0.10
Solution 1
Are you using Chris Lea's PPA? This might be helpful: https://chrislea.com/2013/03/15/upgrading-from-node-js-0-8-x-to-0-10-0-from-my-ppa/
Also to note is that the nodejs-dev and npm packages don’t exist anymore. The new nodejs package contains everything that these separate packages used to, because npm needs all the development files, and you’re not really using node these days if you’re not using npm. So we figured we’d just simplify things with the single package.
The upgrade will uninstall the previous versions, but apt can be a bit obstinate about doing this. Instead of the usual
sudo apt-get update
sudo apt-get upgrade
you will probably instead want to do something like
sudo apt-get update
sudo apt-get -y dist-upgrade
Solution 2
What you're seeing is an bug occuring in certain combinations of node 0.10 and npm versions before 1.2.15.
As Todd points out, the nodejs
Ubuntu package as of 0.10 includes npm
. However, since you previously installed npm
the "old" way i.e. like any other globally installed npm package, the old version (that exhibits the bug) is still picked up from your $PATH
after the upgrade.
Use which npm
to find out whether you get the package installed one from /usr/bin/npm
. If you're still getting the "old" one, remove it (it's only a symlink) and you'll get the "new" version from the Ubuntu package.
Solution 3
Okay. the issue can be resolved by deleting the .npm and .node-gyp directories from the home folder and then reinstalling nodejs again. I am not sure if this is fullproof but it worked for me :)
Related videos on Youtube
Tojo Chacko
Updated on September 18, 2022Comments
-
Tojo Chacko over 1 year
I am on 12.04LTS. I updated my system today and in that process nodejs got updated. Now my npm has stopped working. For e.g:
$ npm install express npm http GET https://registry.npmjs.org/express npm http 200 https://registry.npmjs.org/express npm http GET https://registry.npmjs.org/express/-/express-3.1.0.tgz npm http 200 https://registry.npmjs.org/express/-/express-3.1.0.tgz npm ERR! cb() never called! npm ERR! not ok code 0
Is anyone facing the same issue and knows a fix for this ?
-
Fabio about 11 yearsi'm trying to install brunch and yeoman typing the command npm install -g <packagename> but it fails. I get the same error. Someone suggested to run npm cache clean and try again but it didn't work for me. you may try as well. I'm looking for a solution too.
-
Tojo Chacko about 11 yearsNo npm cache clean does not solve the issue for me too.
-
-
Tojo Chacko about 11 yearsYes, I am using chris lea's ppa. I tried out the steps you mentioned above, but it did not work for me :(
-
kynan about 11 yearsThat's not required, it's sufficient to delete the
npm
binary you installed vianpm
itself, so the package installed binary is being picked up. Find out whichnpm
is being picked up withwhich npm
. -
badsyntax almost 11 yearsI had to remove nodejs, and remove /usr/local/lib/node_modules and relevant symlinks in /usr/local/bin, then re-install nodejs and everything works.