npm 安装权限被拒绝 Mac M1

问题描述 投票:0回答:1

我已经尝试了一切,这仅显示了我尝试过的一英寸,有人可以帮忙吗?我用 a 替换了我的名字,这是我在错误代码中唯一更改的内容

a@Air-von-A kanban % npm install
npm ERR! code EEXIST
npm ERR! syscall mkdir
npm ERR! path /Users/a/.npm/_cacache/content-v2/sha512/0f/7d
npm ERR! errno -13
npm ERR! EACCES: permission denied, mkdir '/Users/a/.npm/_cacache/content-v2/sha512/0f/7d'
npm ERR! File exists: /Users/a/.npm/_cacache/content-v2/sha512/0f/7d
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.

npm ERR! A complete log of this run can be found in: /Users/a/.npm/_logs/2024-01-06T17_01_26_417Z-debug-0.log
a@Air-von-A kanban % sudo npm install -g yarn

added 1 package in 650ms
a@Air-von-A kanban % npm install
npm ERR! code ENOTEMPTY
npm ERR! syscall rename
npm ERR! path /Users/a/Downloads/kanban/node_modules/@vue/compiler-core
npm ERR! dest /Users/a/Downloads/kanban/node_modules/@vue/.compiler-core-ZXEc73Pt
npm ERR! errno -66
npm ERR! ENOTEMPTY: directory not empty, rename '/Users/a/Downloads/kanban/node_modules/@vue/compiler-core' -> '/Users/a/Downloads/kanban/node_modules/@vue/.compiler-core-ZXEc73Pt'

npm ERR! A complete log of this run can be found in: /Users/avissataghizadeh/.npm/_logs/2024-01-06T17_02_33_402Z-debug-0.log
a@Air-von-A kanban % ```
node.js macos vue.js npm-install permission-denied
1个回答
0
投票

您计算机的主目录中的权限存在问题。您可以在每个 npm 命令之前使用

sudo
来修复此问题,但要永久修复此问题而不必每次都执行
sudo
,请运行以下命令:

sudo chown -R $(whoami) ~/.npm

© www.soinside.com 2019 - 2024. All rights reserved.