본문 바로가기

문제 해결

npm install -g serve 시 permission denied 에러 해결

 

 

강의를 듣다가 serve 를 설치하는 부분에서 에러가 났다.

항상 보자마자 긴장부터 되는 빨간색 글자들이지만... 침착하게 구글링을 해보려다가

익숙한(?) 단어에 내가 해결 할 수 있을 것 같은데? 하고 에러에 대한 설명을 쭈루룩 보았다.

 

 

(경로) % npm install -g serve
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/serve
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/serve'
npm ERR!  [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/serve'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: '/usr/local/lib/node_modules/serve'
npm ERR! }
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.

npm ERR! A complete log of this run can be found in:

 

익숙한 단어는 바로 permission denied

접근 권한이 없다는 뜻이다.

 

path(경로) 부분을 보니 '/usr/local/lib/node_modules/serve' 경로에 대한 접근 권한이 없는 모양이다.

이런 경우는 root 권한으로 명령어를 실행 할 수 있도록 해주는 sudo 명령어를 앞에 붙이고 실행하면 된다.

 

나같은 경우는 npm install -g serve 를 입력하면 에러가 나서

sudo npm install -g serve 를 입력해 주었다. 

 

그러면 패스워드를 입력하라고 나올텐데 그때 패스워드를 입력하고 엔터를 쳐주면 완료!

 

sudo 명령어를 함께 치자 정상적으로 작동되는 것이 보인다.

 

 

뭔가 이런 에러(특히나 터미널에서)가 나면 무조건적으로 구글링을 하는 경우가 많았는데

이런 간단한 에러같은 경우는 내가 분석해서 해결하는 것도 좋은 것 같다.

 

끝!!!