Today I Learn (TIL)

#36 JS - Vue CLI EACCES 에러, 권한 에러 뜰때 해결법

이웃집 친구 2020. 11. 11. 18:12
반응형

vue를 사용하기 위해 node js를 설치하고 

npm install -g @vue/cli

입력하고 난 뒤, 

 

Faisals-Mac:Code faisal$ npm uninstall -g react-native-cli
/usr/local/lib/node_modules/react-native-cli/node_modules/winston/node_modules
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules/react-native-cli/node_modules/ansi-styles
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules/react-native-cli/node_modules/ansi-styles'
npm ERR!  { [Error: EACCES: permission denied, access '/usr/local/lib/node_modules/react-native-cli/node_modules/ansi-styles']
npm ERR!   stack:
npm ERR!    'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules/react-native-cli/node_modules/ansi-styles\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path:
npm ERR!    '/usr/local/lib/node_modules/react-native-cli/node_modules/ansi-styles' }
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.

이런 errno -13 permission denied 가 떴다.

 

이 이슈는 NPM폴더(경로)가 접근하고 쓰기를 실행할때 권한 설정이 되어있지 않기 때문에 발생한다.

sudo chown -R `whoami` ~/.npm
sudo chown -R `whoami` /usr/local/lib/node_modules

위와 같이 입력하면 바로 해결된다.

 

위 처럼 해도 안되면 

npm uninstall -g ....

... 에는 지울 항목 필자의 경우 @vue/cli

넣고 삭제 후 재설치하고 다시 시도해보는 것을 추천한다.

 

*** 처음에는 설치가 안되서 sudo npm install 이렇게 했었는데 그래도 안돼서 이방법을 썼다.