【问题标题】:Cannot npm install 'mean-cli' module on Mac OS X无法在 Mac OS X 上安装 'mean-cli' 模块
【发布时间】:2015-10-11 11:50:06
【问题描述】:

更新: 显然,使用sudo 安装节点模块是不好的做法。相反,更改文件夹权限将解决此问题。

在此处查看答案:https://stackoverflow.com/a/31546496/2859315

原帖:

目前,我已经安装了 Node(版本 v0.12.7)和 NPM。我正在尝试从 NPM 安装 mean-cli 包。

我正在按照此处的安装说明进行操作:https://github.com/linnovate/mean#installation

另外,我正在学习关于 Udemy 的 MEAN Stack 开发课程。以下是讲座: https://www.udemy.com/mean-stack-for-beginners/#/lecture/2697540

到目前为止,我已经安装了两个必备包,Gulp 和 Bower:

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

首先,我尝试使用npm install -g mean-cli 进行安装,但没有使用sudo 会引发权限错误。然后,即使使用sudo 也行不通。

其次,我尝试更新和重新安装 node 和 NPM。还是有同样的问题。

当我输入命令sudo npm install -g mean-cli

我收到以下回复:

> mean-cli@0.10.14 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! mean-cli@0.10.14 preinstall: `node ./scripts/preinstall`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the mean-cli@0.10.14 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 mean-cli@0.10.14 preinstall script 'node,但我不确定如何进一步调试。

感谢任何见解或有用的信息!谢谢!

【问题讨论】:

    标签: node.js macos npm mean-stack mean.io


    【解决方案1】:

    要收回 /usr/local 的所有权,请使用以下命令

    sudo chown –r $USER /usr/local

    【讨论】:

    • 不好的建议...这些系统文件应该归 root 拥有,而不是 $USER ...出于众所周知的安全原因,不应使用 sudo 来安装/执行任何 node/npm 命令
    【解决方案2】:

    显然,使用sudo 安装节点模块是不好的做法。相反,更改文件夹权限将解决此问题。

    在此处查看答案:https://stackoverflow.com/a/31546496/2859315

    【讨论】:

      猜你喜欢
      • 2015-12-10
      • 2018-12-06
      • 2016-07-05
      • 2011-01-02
      • 2017-11-02
      • 2011-05-04
      • 2012-10-24
      • 2014-04-29
      相关资源
      最近更新 更多