grunt.js的全局安装失败

我可以使用npm install grunt在本地安装gruntjs

但是,当我试图全局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! <npm-@googlegroups.com> 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 

我能做些什么来安装它?

PS有可能来某些文件夹的权利为root:root ,而不是我的用户。 因为我们的pipe理员安装VM的方式…

我也有这个问题,咕噜和凉亭

我find的解决scheme是在这篇文章NPMconfiguration

在你的.npmrc中你需要设置前缀path

 prefix = /usr/local 

或者你可以从terminal做到这一点:

 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/,手册页根本没有安装。

尝试chowning node_modules文件夹,然后尝试再次安装:

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

遇到同样的问题。 以下为我工作:

 sudo npm install -g grunt-cli 

试试sudo npm install -g grunt

添加选项–no-bin-links的效果很好。 我试了一切,只有这解决了我的问题。 我在ubuntu 12.04上安装了Yeoman,它总是返回错误:

 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