While writing and exploring on Node.js I did lots of ‘yum remove/install’ for npm node.js.
after a while I realized that npm wasn’t installing anything and just returned an Error: cannot find module ‘block-stream’.
Another thing was that the folder ‘/usr/lib/nodejs/npm’ was lacking the ‘node_modules’ folder which includes its dependencies.
yum remove/install npm didn’t helped, the error also happened when I tried running ‘npm update’ or ‘npm install’.
With the help of a few great guys from #Node.js it seems that the current 1.1.44 version of npm might have a bug in the rpm package and that the package is broken on my CentOS.
If you experience it either use the ‘npm-install‘ script instead of yum.
CentOS minimal don’t have the command ‘which‘ which the install script of npm uses during run-time, and because of that you’ll need to create a patch for ‘which’ command. (thanks again marcosnils 😉 )
EDIT: CentOS always had which, I was dumb to override it with the following patch. fix your which, and try the following solution ONLY if you can’t. then REMEMBER to delete the WHICH script below after the installation OR ELSE your future ‘yum install kernel’ will fail.
Which command patch
add a file named ‘which’ in your /bin directory and add inside:
whereis $1 | cut -d ” ” -f2[/code]
[code lang=”bash”]cd /bin
chmod +x which
check with ‘which node’ which should return ‘/usr/bin/node‘ (if you installed using the rpm or repo).
if you don’t have whereis installed just run:
[code lang=”bash”]yum install whereis[/code]
finally, run the following:
[code lang=”bash”]cd /tmp
curl -s http://npmjs.org/install.sh > npm-install-$$.sh
For me, it was npm-install-4691.sh, but it might have another name.
‘npm update’ and/or ‘npm install’ should work for you again now, as it did for me. if not, you can try to
[code lang=”bash”]yum remove npm[/code]
and then install npm again using [code lang=”bash”]yum install npm[/code].
REMEMBER – AFTER YOU FINISH INSTALLING – REMOVE THE ‘WHICH’ script in the /bin folder we’ve added. It will KILL your ‘yum update kernel’!!! . it took me almost 2 years to find out it’s the source of my ‘yum update kernel’ kernel panics!
A little bonus: Now you can install npm using the npm-install script which did not work on CentOS without the ‘which’ mod. 😉