background
Many friends who use MacOS will encounter errors when setting up npm install, as shown in the figure:
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /Users/bcy/.npm/_cacache/index-v5/04/28
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/bcy/.npm"
Next let us solve this problem together!
first step
Enter code:
sudo npm audit fix --force
Then enter the password, as shown in the figure:
At this time, try to enter npm install iquery, and an error is reported. Go to step two, as shown in the figure:
The picture also shows what to enter:
Step 2
According to the picture in step 1, enter the code:
sudo chown -R 501:20 "/Users/bcy/.npm”
Enter the password, as shown in the figure:
third step
Enter npm install jquery again and still get an error
Prompt that the permission settings of the '/Users/bcy/package-lock.json' file need to be set
At this time, modify the file permissions according to the prompts:
Enter npm install jquery again, success! !