When installing the plug-in, such an error occurs. The reason is that the root user used to locally install the npm package, leaving the file with root ownership, which makes the ordinary user unable to access the file content of root.
The error log is as follows:
npm ERR! path /Users/Kyle/.npm/_cacache/index-v5/d8/1f/98ab242d0cbad080828ef3e3f4b864c25e506a719121c293fec810b14b3c npm ERR! code EACCES npm ERR! errno -13 npm ERR! syscall open npm ERR! Error: EACCES: permission denied, open '/Users/Kyle/.npm/_cacache/index-v5/d8/1f/98ab242d0cbad080828ef3e3f4b864c25e506a719121c293fec810b14b3c' npm ERR! { [Error: EACCES: permission denied, open '/Users/Kyle/.npm/_cacache/index-v5/d8/1f/98ab242d0cbad080828ef3e3f4b864c25e506a719121c293fec810b14b3c'] npm ERR! cause: npm ERR! { Error: EACCES: permission denied, open '/Users/Kyle/.npm/_cacache/index-v5/d8/1f/98ab242d0cbad080828ef3e3f4b864c25e506a719121c293fec810b14b3c' npm ERR! errno: -13, npm ERR! code: 'EACCES', npm ERR! syscall: 'open', npm ERR! path: npm ERR! '/Users/Kyle/.npm/_cacache/index-v5/d8/1f/98ab242d0cbad080828ef3e3f4b864c25e506a719121c293fec810b14b3c' }, npm ERR! isOperational: true, npm ERR! stack: npm ERR! 'Error: EACCES: permission denied, open \'/Users/Kyle/.npm/_cacache/index-v5/d8/1f/98ab242d0cbad080828ef3e3f4b864c25e506a719121c293fec810b14b3c\'', npm ERR! errno: -13, npm ERR! code: 'EACCES', npm ERR! syscall: 'open', npm ERR! path: npm ERR! '/Users/Kyle/.npm/_cacache/index-v5/d8/1f/98ab242d0cbad080828ef3e3f4b864c25e506a719121c293fec810b14b3c', npm ERR! parent: 'findup-sync' } npm ERR! npm ERR! The operation was rejected by your operating system. npm ERR! It is likely you do not have the permissions to access this file as the current user npm ERR! npm ERR! If you believe this might be a permissions issue, please double-check the npm ERR! permissions of the file and its containing directories, or try running npm ERR! the command again as root/Administrator (though this is not recommended). npm ERR! A complete log of this run can be found in: npm ERR! /Users/Kyle/.npm/_logs/2019-03-26T07_00_54_812Z-debug.log
Error reason:
Find the error file and you will see that its owner is root.
Before the local installation with root, the owner of this file is root, including the ownership of some folders under the. npm folder, which is also root. Of course, ordinary users
Mistake.
! [picture uploading...]
Solution
That is to change the ownership of the. npm folder under the user directory to the current user.
For example: the current user name is Kyle
sudo chown -R Kyle ~/.npm
After execution, enter the root password. The file has been changed to the current user, and the operation will not appear again.
Matters needing attention
When beginners use terminal to operate npm, they often mix root and ordinary users.
Because of the difference between global installation and local installation, the problem of misuse of root will appear.
Generally speaking, the global installation uses ordinary users.