"sudo npm install -g grunt-cli" gives me an error

I get an error when trying to install gruntjs on Linux 12.04 (with source mirror packages)

Here is the error:

sudo npm install -g grunt-cli npm ERR! Error: ENOENT, open '/home/havetl/.npm/d63f3d0b-grunt-cli.lock' npm ERR! If you need help, you may report this log at: npm ERR! <http://github.com/isaacs/npm/issues> npm ERR! or email it to: npm ERR! < npm-@googlegroups.com > npm ERR! System Linux 3.5.0-23-generic npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "-g" "grunt-cli" npm ERR! cwd /home/havetl npm ERR! node -v v0.10.18 npm ERR! npm -v 1.3.8 npm ERR! path /home/havetl/.npm/d63f3d0b-grunt-cli.lock npm ERR! code ENOENT npm ERR! errno 34 npm ERR! Error: EACCES, open 'npm-debug.log' npm ERR! { [Error: EACCES, open 'npm-debug.log'] errno: 3, code: 'EACCES', path: 'npm-debug.log' } npm ERR! npm ERR! Please try running this command again as root/Administrator. npm ERR! System Linux 3.5.0-23-generic npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "-g" "grunt-cli" npm ERR! cwd /home/havetl npm ERR! node -v v0.10.18 npm ERR! npm -v 1.3.8 npm ERR! path npm-debug.log npm ERR! code EACCES npm ERR! errno 3 npm ERR! stack Error: EACCES, open 'npm-debug.log' npm ERR! npm ERR! Additional logging details can be found in: npm ERR! /home/havetl/npm-debug.log npm ERR! not ok code 0 

Thanks for any idea!

+1
source share
3 answers

According to an accompanying npm, installing packages with sudo is considered bad practice because you allow this package to completely control your system, and you cannot and DO NOT trust these packages with root access. Think of long Debian cycles as an extreme example of protecting end users from community-supported packages for this reason.

http://howtonode.org/introduction-to-npm

You must do what Issaacs offers and chown your /usr/local folder so that you have RW permissions.

+4
source

I had this problem before; sometimes for global packages your current working directory should be ~/ (but I'm not sure why this is!). Try:

 cd ~/; sudo npm install -g grunt-cli 
+3
source

This blog worked for me:

http://slopjong.de/2012/10/31/how-to-install-the-latest-nodejs-in-ubuntu/

the error was that in ubuntu v12 some of the dependencies were not available for the latest version of Node.

0
source

All Articles