npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/nodemon
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir'/usr/local/lib/node_modules/nodemon'
npm ERR! [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/nodemon'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/usr/local/lib/node_modules/nodemon'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
看起來問題出在包 generator-karma 上,不確定這是否是問題所在。
誰能告訴我我需要做什么才能正確安裝。
謝謝薩尼爾
uj5u.com熱心網友回復:
這看起來像是您的主目錄中的權限問題。要收回 node_modules 目錄的所有權,請執行:
sudo chown -R $(whoami) ~/node_modules
uj5u.com熱心網友回復:
Node.js 錯誤EACCES意味著您無權訪問它指定的路徑。在這種情況下,/usr/local/lib/...歸root用戶所有。在此處查看命令輸出:
$ ls -l /usr/local/lib
total 12
drwxr-xr-x 4 root root 4096 Apr 7 23:45 node_modules
除了 root 之外,沒有人可以寫入該node_modules檔案夾。這可以通過為您的 npm 命令添加前綴來以rootsudo身份運行命令來解決。
查看其他:了解 Linux 檔案權限 - Linuxize
uj5u.com熱心網友回復:
我相信您正在嘗試通過使用在您的系統上安裝一個全域包npm install -g nodemon,然后獲得權限被拒絕,這顯示在錯誤訊息中。
沒有 root 權限,您無法安裝全域包。如果您想這樣做,只需使用 root 權限執行它,例如使用 sudo:sudo npm i -g nodemon或切換到 root 然后再次執行。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/468122.html
下一篇:在服務器運行時運行命令?
