2012-11-23 31 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