Mac npm权限 sh: vite: command not found

751 阅读1分钟

执行npm run dev 报错如下

sh: vite: command not found

可能是因为没有安装依赖,再次执行npm i,又报错如下

npm ERR! code EACCES
npm ERR! syscall open
npm ERR! path /Users/xxx/.npm/_cacache/index-v5/d7/77/eacbd62336b909a018f2a82d1d3b1a5b59fa9428e409fcfc22a4b5fd012d
npm ERR! errno EACCES
npm ERR! 
npm ERR! Your cache folder contains root-owned files, due to a bug in
npm ERR! previous versions of npm which has since been addressed.
npm ERR! 
npm ERR! To permanently fix this problem, please run:
npm ERR!   sudo chown -R 501:20 "/Users/xxx/.npm"

npm ERR! A complete log of this run can be found in: /Users/xxx/.npm/_logs/2024-08-01T01_29_04_596Z-debug-0.log

执行

sudo chown -R 501:20 "/Users/xxx/.npm"