2015-07-21 56 views
2

更新: 顯然,使用sudo來安裝節點模塊是不好的做法。相反,更改文件夾權限將解決此問題。無法在Mac OS X上安裝'mean-cli'模塊

在這裏看到了答案:https://stackoverflow.com/a/31546496/2859315

原貼:

目前,我已經安裝節點(版本v0.12.7)和NPM。我正在嘗試安裝來自NPM的mean-cli程序包。

我下面在這裏找到安裝說明:https://github.com/linnovate/mean#installation

另外,我正在上Udemy平均堆棧的發展歷程。以下是演講: https://www.udemy.com/mean-stack-for-beginners/#/lecture/2697540

到目前爲止,我已經安裝了這兩個必備程序包,杯和鮑爾:

$ npm install -g gulp 
// and bower 
$ npm install -g bower 

首先,我嘗試用npm install -g mean-cli安裝,但拋出權限錯誤,而無需使用sudo。然後,即使使用sudo也不行。

其次,我嘗試更新並重新安裝節點和NPM。仍然有同樣的問題。

當我鍵入命令sudo npm install -g mean-cli

我得到這樣的迴應:

> [email protected] preinstall /usr/local/lib/node_modules/mean-cli 
> node ./scripts/preinstall 

shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied 
node.js:720 
    var cwd = process.cwd(); 
       ^
Error: EACCES, permission denied 
    at Error (native) 
    at Function.startup.resolveArgv0 (node.js:720:23) 
    at startup (node.js:63:13) 
    at node.js:814:3 
npm ERR! Darwin 14.4.0 
npm ERR! argv "node" "/usr/local/bin/npm" "install" "-g" "mean-cli" 
npm ERR! node v0.12.7 
npm ERR! npm v2.11.3 
npm ERR! code ELIFECYCLE 

npm ERR! [email protected] preinstall: `node ./scripts/preinstall` 
npm ERR! Exit status 1 
npm ERR! 
npm ERR! Failed at the [email protected] preinstall script 'node ./scripts/preinstall'. 
npm ERR! This is most likely a problem with the mean-cli package, 
npm ERR! not with npm itself. 
npm ERR! Tell the author that this fails on your system: 
npm ERR!  node ./scripts/preinstall 
npm ERR! You can get their info via: 
npm ERR!  npm owner ls mean-cli 
npm ERR! There is likely additional logging output above. 

npm ERR! Please include the following file with any support request: 
npm ERR!  /Library/WebServer/Documents/NodeJS/mean/npm-debug.log 

好像問題就出在這裏:Failed at the [email protected] preinstall script 'node,但我不知道如何繼續調試。

任何洞察力或有用的信息表示讚賞!謝謝!

回答

-1

爲了收回在/ usr /本地使用的所有權的命令之下

須藤喬敦 - R的$ USER的/ usr /本地

+1

糟糕的建議......那些系統文件應該由root擁有而不是$ USER ... sudo不應該用於安裝/執行任何節點/ npm命令以實現衆所周知的安全原因 –