2015-07-21 139 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命令以实现众所周知的安全原因 –