1

当我尝试使用 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 错误错误:ENOENT, chmod

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

“上述操作导致在 ~/.npm/ 目录中安装了一些依赖项,具有 root:root 所有权(因为 sudo ...)。显然,在拉取依赖项和将它们写入本地用户子目录 ~/.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"

任何帮助,将不胜感激。

4

2 回答 2

0

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

在这里查看:https ://groups.google.com/forum/#!topic/gnu.bash.bug/JkcxWDfilZI

您位于只能由 root 读取和搜索的目录中,并且您正在向另一个用户发起诉讼。该用户无权搜索当前目录,甚至无法找到“..”,因此 getcwd 将失败。

于 2014-08-30T04:09:12.027 回答
0

我遇到了类似的问题,发现权限问题在我的根用户目录 /User/tomk/.npm 中的基本 npm 目录上。npm 的子目录归 root 所有(可能是因为必须 sudo 才能安装 node/npm)。一旦我将所有权更改为我的帐户,meanio 安装时没有出现致命错误(很多警告,但没有停止安装)。

于 2014-09-30T16:21:09.040 回答