我正在尝试在 nodejs 中安装 yo 和其他一些软件包,但是我不断收到错误。我是节点新手,所以我有点迷失。
我运行的是 Mac OS X 10.10.3。我正在使用的命令是
sudo npm install --global yo
这样做会给我带来以下错误。
> [email protected] /cdn-cgi/l/email-protection postinstall /usr/local/lib/node_modules/yo/node_modules/cross-spawn/node_modules/spawn-sync
> node postinstall
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.3.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "--global" "yo"
npm ERR! node v0.12.7
npm ERR! npm v2.11.3
npm ERR! code ELIFECYCLE
npm ERR! [email protected] /cdn-cgi/l/email-protection postinstall: `node postinstall`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] /cdn-cgi/l/email-protection postinstall script 'node postinstall'.
npm ERR! This is most likely a problem with the spawn-sync package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node postinstall
npm ERR! You can get their info via:
npm ERR! npm owner ls spawn-sync
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/XXXXXXX/npm-debug.log
一般来说,您不应该使用 sudo 来安装节点模块。
相反,请使用 sudo 修复文件夹权限,以允许您进行全局 npm 安装。
获取 .npm 目录的所有权
sudo chown -R $(whoami) ~/.npm
并具有对 node_modules 目录的写入权限
sudo chown -R $USER /usr/local/lib/node_modules
然后尝试再次运行 npm install 命令without sudo.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)