배경
MacOS를 사용하는 많은 친구들은 npm 설치를 설정할 때 그림과 같이 오류가 발생합니다.
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"
다음으로 우리 함께 이 문제를 해결해 볼까요!
첫 번째 단계
코드를 입력:
sudo npm audit fix --force
그런 다음 그림과 같이 비밀번호를 입력하십시오.
이때 npm install query를 입력하려고 하면 오류가 보고되며 그림과 같이 2단계로 이동합니다.
그림에는 입력할 내용도 나와 있습니다.
2 단계
1단계의 그림에 따라 코드를 입력하세요.
sudo chown -R 501:20 "/Users/bcy/.npm”
그림과 같이 비밀번호를 입력하세요.
세 번째 단계
npm install jquery를 다시 입력해도 여전히 오류가 발생합니다.
'/Users/bcy/package-lock.json' 파일의 권한 설정을 지정해야 한다는 메시지를 표시합니다.
이때 프롬프트에 따라 파일 권한을 수정합니다.
npm install jquery를 다시 입력하면 성공합니다! !