使用npm在Mac OS X上安装MEANIO时出现问题

时间:2014-08-29 10:02:51

标签: node.js npm failed-installation mean.io

当我尝试使用npm在我的Mac上安装MEANIO时,我遇到了几个安装失败的错误。错误如下所示:

有两种主要类型的问题:一种是Error EACCES,另一种是ERROR ENOENT。我尝试了几种解决方案,这些解决方案并没有多大帮助。

1. sudo npm clear cache 
2. sudo npm update -g
3. Permission fix: by changing nodejs folder's permission to local user 

(参阅:npm install errors with Error: ENOENT, chmod

我想知道造成这个问题的原因。由于我没有发布我自己的应用程序,因此无法根据链接中提供的解决方案包含.npmignore。该链接中的第二个答案声称问题的性质是:

  

“上面的操作导致一些依赖项被安装在〜/ .npm / dir中,拥有root:root所有权(因为sudo ...)。显然npm不会以本地用户身份运行(或者之后更改依赖关系子目录所有权)拉动依赖关系并将它们写入本地用户子目〜/ .npm /。只要npm对基本的unix文件系统安全问题如此粗心,问题就会再次发生。“

我怀疑这是否正确。安装MEANIO不应该造成太多问题。

shell命令和错误消息如下所示:

localhost:local Nick_Guan$ sudo npm install -g meanio@latest
npm WARN engine meanio@0.6.6: wanted: {"node":"0.10.x","npm":"1.4.x"} (current:         {"node":"0.10.31","npm":"2.0.0-beta.1"})
npm WARN engine npm@1.5.0-alpha-4: wanted: {"node":">=0.8","npm":"1"} (current: {"node":"0.10.31","npm":"2.0.0-beta.1"})

> mean-health@0.1.5 postinstall /usr/local/lib/node_modules/meanio/node_modules/mean-health
> node postinstall

shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied

node.js:815
var cwd = process.cwd();
                  ^
Error: EACCES, permission denied
at Function.startup.resolveArgv0 (node.js:815:23)
at startup (node.js:58:13)
at node.js:906:3
npm ERR! Error: ENOENT, chown '/usr/local/lib/node_modules/meanio/node_modules/prompt/test/prompt-test.js'
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR!     <http://github.com/npm/npm/issues>

npm ERR! System Darwin 13.1.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "meanio@latest"
npm ERR! cwd /usr/local
npm ERR! node -v v0.10.31
npm ERR! npm -v 2.0.0-beta.1
npm ERR! path /usr/local/lib/node_modules/meanio/node_modules/prompt/test/prompt-test.js
npm ERR! fstream_path /usr/local/lib/node_modules/meanio/node_modules/prompt/test/prompt-test.js
npm ERR! fstream_type File
npm ERR! fstream_class FileWriter
npm ERR! fstream_finish_call chown
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/fstream/lib/writer.js:308:19
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/graceful-fs/polyfills.js:143:7
npm ERR! fstream_stack Object.oncomplete (evalmachine.<anonymous>:107:15)
npm ERR! Error: ENOENT, chmod '/usr/local/lib/node_modules/meanio/node_modules/npm/bin/npm-cli.js'
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR!     <http://github.com/npm/npm/issues>

npm ERR! System Darwin 13.1.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "meanio@latest"
npm ERR! cwd /usr/local
npm ERR! node -v v0.10.31
npm ERR! npm -v 2.0.0-beta.1
npm ERR! path /usr/local/lib/node_modules/meanio/node_modules/npm/bin/npm-cli.js
npm ERR! fstream_path /usr/local/lib/node_modules/meanio/node_modules/npm/bin/npm-cli.js
npm ERR! fstream_type File
npm ERR! fstream_class FileWriter
npm ERR! fstream_finish_call chmod
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/fstream/lib/writer.js:308:19
npm ERR! fstream_stack Object.oncomplete (evalmachine.<anonymous>:107:15)
npm ERR! Error: ENOENT, chown '/usr/local/lib/node_modules/meanio/node_modules/bower/lib/config.js'
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR!     <http://github.com/npm/npm/issues>

npm ERR! System Darwin 13.1.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "meanio@latest"

任何帮助都将不胜感激。

2 个答案:

答案 0 :(得分:0)

仔细检查是否正确安装了先决条件,确保在主目录下的某个位置执行install命令。

点击此处:https://groups.google.com/forum/#!topic/gnu.bash.bug/JkcxWDfilZI

  

您位于可以阅读的目录中   仅由root搜索,并且您已经转到其他用户。那个用户   没有权限搜索当前目录,甚至找不到   `..&#39;,所以getcwd会失败。

答案 1 :(得分:0)

我遇到了类似的问题,发现权限问题出现在我的root用户目录/User/tomk/.npm的基本npm目录中。 npm的子目录由root拥有(可能来自sudo以安装node / npm)。一旦我将所有权更改为我的帐户,就安装了meanio而没有致命错误(许多警告,但没有什么可以阻止安装)。