npm 전역 설치 오류

김동현·2023년 10월 27일
0

이슈 일기

목록 보기
1/6

문제 상황
pnpm 패키지 매니저를 전역으로 설치하려고 아래와 같은 명령어를 터미널에서 실행시켰지만

npm install -g npm@latest

아래와 같은 에러 로그를 띄우면서 설치가 되지 않는다.

npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/pnpm
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/pnpm'
npm ERR!  [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/pnpm'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: '/usr/local/lib/node_modules/pnpm'
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:
npm ERR!     /Users/gimdonghyeon/.npm/_logs/2023-10-27T09_41_01_116Z-debug-0.log

이해
위 에러를 자세히 살펴보면 아래와 같은 설명을 볼 수 있는데,'/usr/local/lib/node_modules/pnpm' 해당 경로에 대한 권한이 내부적으로 없기 때문에 발생하는 문제였다.

npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/pnpm'

해결
경로에 대한 권한만 부여해 주면 해결되는 문제 이기 때문에 아래와 같이 'sudo' 명령어를 앞쪽에 덧 붙여주면 문제 없이 전역적으로 패키지를 설치 할 수 있다.

npm install -g npm@latest
profile
有備無患 : 미리 대비하고 있으면 걱정할 일이 없다

0개의 댓글