我正在嘗試創建一個新專案并想在我的專案目錄中安裝 NPM,但它顯示了這些錯誤。我目前擁有最新版本的 NPM 和 Node.js。
Naomis-Air:~ naomivictoriaobame$ npm -v
7.24.0
Naomis-Air:~ naomivictoriaobame$ npm install npm@latest -g
npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /usr/local/lib/node_modules/npm
npm ERR! dest /usr/local/lib/node_modules/.npm-i9nnxROI
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/npm' -> '/usr/local/lib/node_modules/.npm-i9nnxROI'
npm ERR! [Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/npm' -> '/usr/local/lib/node_modules/.npm-i9nnxROI'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rename',
npm ERR! path: '/usr/local/lib/node_modules/npm',
npm ERR! dest: '/usr/local/lib/node_modules/.npm-i9nnxROI'
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/naomivictoriaobame/.npm/_logs/2021-10-16T20_55_50_627Z-debug.log
Naomis-Air:~ naomivictoriaobame$ npm cache clean --force
npm WARN using --force Recommended protections disabled.
Naomis-Air:~ naomivictoriaobame$
uj5u.com熱心網友回復:
看起來當前用戶需要權限才能更改 npm 目錄。您可以運行以下命令以授予當前用戶訪問權限來修改該目錄:
sudo chown -R $(whoami) ~/.npm
uj5u.com熱心網友回復:
您必須使用sudo, 才能進行-g全域安裝:
sudo npm install npm@latest -g
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/330745.html
上一篇:打開鏡頭應用程式時修復錯誤權限被拒絕“/Users/name/Library/ApplicationSupport/Lens/node_modules/lenscloud-lens-extension
下一篇:@typescript-eslint/eslint-plugin已安裝,但在vscodelint任務中拋出錯誤并要求使用不存在的@typescript-eslint包
