“sudo npm安装-g grunt-cli”给了我一个错误。

时间:2022-10-07 09:47:34

I get an error when trying to install gruntjs on a linux 12.04 (with a mirrored packages source)

尝试在linux 12.04上安装gruntjs(带有镜像的包源)时,会出现错误。

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!

谢谢你的任何想法!

3 个解决方案

#1


4  

According to the maintainer of npm, installing packages with sudo is considered bad practice because you are allowing that package to have complete control of your system and you can't and SHOULDN'T trust these packages with root access. Think Debian's long release cycles as an extreme example of protecting end users from community maintained packages for this exact reason.

根据npm的维护人员,安装sudo包被认为是糟糕的实践,因为您允许该包对您的系统有完全的控制,您不能也不应该信任这些带有root访问权限的包。认为Debian的长发布周期是保护终端用户免受社区维护包的极端例子。

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

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

You should do what Issaacs suggests and chown your /usr/local folder so you have RW permissions.

您应该执行Issaacs建议的操作,并且chown您的/usr/local文件夹,这样您就有RW权限。

#2


3  

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

我以前遇到过这个问题;有时候,对于全局包,您当前的工作目录必须是~/(但我不知道为什么是这样!)试一试:

cd ~/; sudo npm install -g grunt-cli

#3


0  

This blog worked for me :

这个博客为我工作:

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

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

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

错误在于,在ubuntu v12中,没有几个依赖项可以用于最新版本的节点。

#1


4  

According to the maintainer of npm, installing packages with sudo is considered bad practice because you are allowing that package to have complete control of your system and you can't and SHOULDN'T trust these packages with root access. Think Debian's long release cycles as an extreme example of protecting end users from community maintained packages for this exact reason.

根据npm的维护人员,安装sudo包被认为是糟糕的实践,因为您允许该包对您的系统有完全的控制,您不能也不应该信任这些带有root访问权限的包。认为Debian的长发布周期是保护终端用户免受社区维护包的极端例子。

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

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

You should do what Issaacs suggests and chown your /usr/local folder so you have RW permissions.

您应该执行Issaacs建议的操作,并且chown您的/usr/local文件夹,这样您就有RW权限。

#2


3  

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

我以前遇到过这个问题;有时候,对于全局包,您当前的工作目录必须是~/(但我不知道为什么是这样!)试一试:

cd ~/; sudo npm install -g grunt-cli

#3


0  

This blog worked for me :

这个博客为我工作:

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

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

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

错误在于,在ubuntu v12中,没有几个依赖项可以用于最新版本的节点。