2012-11-23 25 views
9

我可以在本地使用npm install grunt安装gruntjsgrunt.js的全局安装失败

但是,当我试图在全球范围内安装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 

随着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 

我能做什么来安装它?

P.S.有些文件夹的版权可能是root:root,而不是我的用户。安装的Cuz我们的虚拟机的管理员这样...

+3

尝试' npm cache clean'首先。 –

+1

我已经使用过它。我该怎么办? – ValeriiVasin

+0

似乎喜欢它取决于节点安装类型:本地或全球... – ValeriiVasin

回答

4

尝试chowning的node_modules文件夹,然后尝试重新安装:

sudo chown -R $USER /path/to/node_modules/folder 
+0

当我被告知'sudo npm'不是一个命令时,此方法为我工作 – iabw

3

尝试sudo npm install -g grunt

+0

谢谢,这有助于我的情况 – Andrija

10

我有这个问题太有呻吟,亭子

我已经找到了解决方案是本文NPM config

在你.npmrc你需要设置前缀路径

prefix = /usr/local 

也可以从终端像这样做:

npm config set prefix "/usr/local" 

这样的节点将知道在哪里安装:

在NPM 1.0,有两种方法安装的东西:

全球 - 这滴在{PREFIX}/lib目录/ node_modules模块,并把可执行文件在{prefix}/bin中,其中{prefix}通常是/ usr/local。如果提供的话,它还会在{prefix}/share/man中安装手册页。

本地 - 这会将您的软件包安装在当前工作目录中。节点模块进入./node_modules,可执行文件进入./node_modules/.bin/,手册页根本没有安装。

4

遇到同样的问题。对我来说,以下工作:

sudo npm install -g grunt-cli 
3

添加选项--no斌链接做工不错。我尝试了一切,只有这解决了我的问题。我在Ubuntu 12.04安装自耕农和它总是返回错误:

npm ERR! Error: EACCES, symlink '../lib/node_modules/yo/cli.js' 

然后,我所做的:

npm install -g --no-bin-links yo 

= d

详情https://github.com/isaacs/npm/issues/2380