使用nvm切换默认版本后npm版本已经变换,但是安装依赖包npm i 下载依赖的时候报错
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/xxxxx/.npm”
npm ERR! code EACCES
npm ERR! syscall open
npm ERR! path /Users/xxxxx/.npm/_cacache/index-v5/4d/c3/
看到后面是npm 权限问题,而且报警很贴心提示:要想修复这个问题,请运行:
sudo chown -R 501:20 “/Users/xxxxx/.npm” // 本句对应上方第6行提示
直接CV大法回车,在npm i就可以运行了。