DevEco运行提示“npm ERR! EACCES: permission denied, mkdir '/Users/apple/.npm/_cacache/conten”

报错信息

/Applications/DevEco-Studio.app/Contents/tools/node/bin/node /Applications/DevEco-Studio.app/Contents/tools/hvigor/bin/hvigorw.js --sync -p product=default --analyze=normal --parallel --incremental --no-daemon
Installing pnpm@8.13.1...
npm ERR! code EEXIST
npm ERR! syscall mkdir
npm ERR! path /Users/apple/.npm/_cacache/content-v2/sha512/75/8b
npm ERR! errno -13
npm ERR! EACCES: permission denied, mkdir '/Users/apple/.npm/_cacache/content-v2/sha512/75/8b'
npm ERR! File exists: /Users/apple/.npm/_cacache/content-v2/sha512/75/8b
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/apple/.npm/_logs/2024-12-25T09_06_10_961Z-debug-0.log
Error: /Applications/DevEco-Studio.app/Contents/tools/node/bin/npm install,pnpm execute failed.See above for details.

Process finished with exit code 255

解决方案:
你可以通过更改 .npm 目录的权限来确保当前用户有足够的权限来访问和写入该目录。

sudo chown -R $(whoami) ~/.npm
image.png
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容