Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node.js : NPM Install Fails

I get this error if I run

curl http://npmjs.org/install.sh | sh

even with sudo.

    cirk@cirk-Parallels-Virtual-Platform:~$ curl http://npmjs.org/install.sh | sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  3902  100  3902    0     0   6138      0 --:--:-- --:--:-- --:--:-- 12546
fetching: http://registry.npmjs.org/npm/-/npm-1.0.18.tgz
0.4.9
1.0.18
Skipping 0.x cruft clean
! [ -d .git ] || git submodule update --init --recursive
node cli.js cache clean
node cli.js rm npm -g -f --loglevel error
node cli.js install -g -f
npm ERR! error installing [email protected] Error: EACCES, Permission denied '../lib/node_modules/npm/bin/npm.js'
npm ERR! Error: EACCES, Permission denied '../lib/node_modules/npm/bin/npm.js'
npm ERR! 
npm ERR! Please use 'sudo' or log in as root to run this command.
npm ERR! 
npm ERR!     sudo npm "install" "-g" "-f"
npm ERR! 
npm ERR! or set the 'unsafe-perm' config var to true.
npm ERR! 
npm ERR!     npm config set unsafe-perm true
npm ERR! 
npm ERR! System Linux 2.6.38-10-generic
npm ERR! command "node" "/tmp/npm.1568/package/cli.js" "install" "-g" "-f"
npm ERR! cwd /tmp/npm.1568/package
npm ERR! node -v v0.4.9
npm ERR! npm -v 1.0.18
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /tmp/npm.1568/package/npm-debug.log
npm not ok
It worked

What should I do? I tried these with no success:

chown -R cirk /usr/lib/nodejs
// and also this
chown -R cirk /usr/lib/node_modules (node_modules is empty it tries to install NPM here or what)

actually it did something, as you can see it writes at the end It worked what is a big lie!

like image 872
Adam Halasz Avatar asked Jul 19 '11 19:07

Adam Halasz


2 Answers

Why are you running that in /usr?

If you really need to, this page suggests you may run that as root, so that would be:

curl https://www.npmjs.com/install.sh | sudo sh

But you better make sure it won't break your system, before running that.

like image 170
alex Avatar answered Oct 21 '22 20:10

alex


I screwed up the permissions on my npm installation, and had this error when reinstalling. I solved it in the crudest way: by liberally sudo rm -rfing any directory tree that gave me trouble, then recompiling node.js and reinstalling npm.

If all else fails, you could fall back to that.

like image 45
Jeremy Avatar answered Oct 21 '22 21:10

Jeremy