![](/img/trans.png)
[英]npm ERR! code EACCES, npm install --global yarn met error
[英]npm install -g failing, getting npm ERR! code EACCES
當我運行npm install -g typescript
時,顯示以下消息:
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/typescript
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/typescript'
npm ERR! [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/typescript'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/usr/local/lib/node_modules/typescript'
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:
npm ERR! /Users/alexz/.npm/_logs/2021-12-26T10_45_08_412Z-debug.log
我試圖檢查我是否已成功安裝 TypeScript,如果我運行npm ls typescript
它顯示:
alexz@ /Users/alexz
└── typescript@4.5.4
我是否安裝了 TypeScript 感到困惑,因為如果我執行tsc -v
它會告訴我找不到tsc
命令。 如何解決上述問題? 謝謝!
這是一個權限問題。 使用sudo
命令,它會詢問您的計算機密碼。
sudo npm install -g typescript
不要使用 sudo 安裝全局包! 看起來全局 npm 安裝了錯誤的權限請檢查全局 npm 是由哪個用戶使用的
which npm | xargs ls -ltrh
然后在此處更改 node_modules 目錄權限
/usr/local/lib/node_modules/typescript'
使用chown
命令對同一用戶
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.