change your file permissions .. like this
first check who owns the directory
ls -la /usr/local/lib/node_modules it is denying access because the node_module folder is owned by root
drwxr-xr-x 3 root wheel 102 Jun 24 23:24 node_modules so this needs to be changed by changing root to your user but first run command below to check your current user How do I get the name of the active user via the command line in OS X?
id -un OR
whoami
then change owner
sudo chown -R [owner]:[owner] /usr/local/lib/node_modules OR
sudo chown -R ownerName: /usr/local/lib/node_modules OR
sudo chown -R $USER /usr/local/lib/node_modules
2021.2.19 更新,不知道是 vite 的提示还是 npm 官方提示:
npm ERR! errno -13 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/a10.12/.npm"