[英]npm install not working, throwing errors
我試圖在nodejs中安裝yo和一些其他軟件包,但是我一直在收到錯誤。 我是節點的新手,所以我有點迷茫。 我正在運行Mac OS X 10.10.3。 我正在使用的命令是
sudo npm install --global yo
這樣做會給我帶來以下錯誤。
> spawn-sync@1.0.13 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! spawn-sync@1.0.13 postinstall: `node postinstall`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the spawn-sync@1.0.13 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
然后嘗試在沒有 sudo的情況下再次運行npm install命令。
從你的Reddit帖子中,我知道sudo npm cache clean
為你修復了這個問題。 想有人應該在這里回答,所以任何想要解決這個問題的人都可以找到它。
運行以下命令應該可以解決問題。
sudo npm cache clean
sudo npm install -g yo
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.