javascript grunt.js 的全局安装失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13527889/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Global installation of grunt.js fails
提问by ValeriiVasin
I could install gruntjs
locally using npm install grunt
.
我可以gruntjs
使用npm install grunt
.
But when I'm trying to install it globally npm install grunt -g
, i'm getting an error:
但是当我尝试全局安装时npm install grunt -g
,出现错误:
npm ERR! Error: EACCES, symlink '../lib/node_modules/grunt/bin/grunt'
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR!
npm ERR! System Linux 2.6.18-92.el5xen
npm ERR! command "nodejs" "/usr/bin/npm" "install" "grunt" "-g"
npm ERR! cwd /home/lj
npm ERR! node -v v0.6.18
npm ERR! npm -v 1.1.19
npm ERR! path ../lib/node_modules/grunt/bin/grunt
npm ERR! code EACCES
npm ERR! message EACCES, symlink '../lib/node_modules/grunt/bin/grunt'
npm ERR! errno {}
npm ERR! Error: EACCES, open 'npm-debug.log'
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR!
npm ERR! System Linux 2.6.18-92.el5xen
npm ERR! command "nodejs" "/usr/bin/npm" "install" "grunt" "-g"
npm ERR! cwd /home/lj
npm ERR! node -v v0.6.18
npm ERR! npm -v 1.1.19
npm ERR! path npm-debug.log
npm ERR! code EACCES
npm ERR! message EACCES, open 'npm-debug.log'
npm ERR! errno {}
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/lj/npm-debug.log
npm not ok
With sudo
I have error too:
与sudo
我有错误太:
npm ERR! Error: spawn ENOENT
npm ERR! at errnoException (child_process.js:483:11)
npm ERR! at ChildProcess.spawn (child_process.js:446:11)
npm ERR! at child_process.js:342:9
npm ERR! at Object.execFile (child_process.js:252:15)
npm ERR! at uidNumber (/usr/lib/nodejs/uid-number/uid-number.js:33:17)
npm ERR! at loadUid (/usr/lib/nodejs/npm/lib/npm.js:336:5)
npm ERR! at Array.2 (/usr/lib/nodejs/bind-actor.js:15:8)
npm ERR! at LOOP (/usr/lib/nodejs/chain.js:15:13)
npm ERR! at /usr/lib/nodejs/chain.js:18:7
npm ERR! at setUser (/usr/lib/nodejs/npm/lib/npm.js:346:32)
npm ERR! You may report this log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <[email protected]>
npm ERR!
npm ERR! System Linux 2.6.18-92.el5xen
npm ERR! command "nodejs" "/usr/bin/npm" "install" "grunt" "-g"
npm ERR! cwd /home/lj
npm ERR! node -v v0.6.18
npm ERR! npm -v 1.1.19
npm ERR! syscall spawn
npm ERR! code ENOENT
npm ERR! message spawn ENOENT
npm ERR! errno {}
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/lj/npm-debug.log
npm not ok
What could I do to install it?
我该怎么做才能安装它?
P.S. It's possible that come rights for some folders is for root:root
, not for my user. Cuz our admins installed VM that way...
PS 某些文件夹的权限可能是针对 的root:root
,而不是针对我的用户的。因为我们的管理员以这种方式安装了 VM...
回答by Joe
I've had this problem too with grunt and bower
我在 grunt 和 bower 上也遇到过这个问题
The solution I've found is in this article NPM config
我在这篇文章中找到的解决方案NPM config
In your .npmrc you need to set the prefix path
在您的 .npmrc 中,您需要设置前缀路径
prefix = /usr/local
or you can do it from terminal like this:
或者您可以像这样从终端执行此操作:
npm config set prefix "/usr/local"
This way node will know where to install them:
这样节点就会知道在哪里安装它们:
In npm 1.0, there are two ways to install things:
在 npm 1.0 中,有两种安装方式:
globally —- This drops modules in {prefix}/lib/node_modules, and puts executable files in {prefix}/bin, where {prefix} is usually something like /usr/local. It also installs man pages in {prefix}/share/man, if they're supplied.
global --- 这将模块放在 {prefix}/lib/node_modules 中,并将可执行文件放在 {prefix}/bin 中,其中 {prefix} 通常类似于 /usr/local。它还会在 {prefix}/share/man 中安装手册页(如果提供的话)。
locally —- This installs your package in the current working directory. Node modules go in ./node_modules, executables go in ./node_modules/.bin/, and man pages aren't installed at all.
本地 --- 这会将您的软件包安装在当前工作目录中。节点模块在 ./node_modules 中,可执行文件在 ./node_modules/.bin/ 中,并且根本没有安装手册页。
回答by Sindre Sorhus
Try chowning the node_modules folder and then try to install again:
尝试 chowning node_modules 文件夹,然后再次尝试安装:
sudo chown -R $USER /path/to/node_modules/folder
回答by Raja Ramu
Encountered same issue. The following works for me:
遇到同样的问题。以下对我有用:
sudo npm install -g grunt-cli
回答by Wellington Lorindo
Adding the option --no-bin-linksworks good. I tried everything and only this solved my problem. I was installing the Yeoman on ubuntu 12.04 and it was always returning the error:
添加选项--no-bin-links效果很好。我尝试了一切,只有这解决了我的问题。我在 ubuntu 12.04 上安装 Yeoman,它总是返回错误:
npm ERR! Error: EACCES, symlink '../lib/node_modules/yo/cli.js'
Then, I did:
然后,我做了:
npm install -g --no-bin-links yo
=D
=D
For more details https://github.com/isaacs/npm/issues/2380
回答by Sayanee
try sudo npm install -g grunt
?
试试sudo npm install -g grunt
?