NPM install -g 로 모듈을 설치하는 데, 예상치 못한 ‘user “root” does not have permission to access the dev dir’ 에러를 만났습니다. 뭔가 파일 권한 관련해서 문제가 발생한 것 같은데, 왜 발생한 건지 원인은 찾지 못했습니다.
구글링 해보면, 일부에서 --unsafe-perm 옵션을 주는 것으로 해결한 사례를 찾았습니다. 또 일부는 xcode 문제라고 하기도 했습니다.
--unsafe-perm은 왠지, unsafe라는 단어가 맘에 들지 않았을 뿐더러, 문제를 피해가는 꼼수라고 생각이 들었습니다. 두번 째 xcode 문제는 저에게는 해당 되지 않는 문제였습니다. 저는 ubuntu를 사용 중이었으니까요.
그러던 중 NPM 공식 문서 중 “Resolving EACCES permissions errors when installing packages globally”를 발견하였습니다. 문제를 해결하는 방법을 두가지를 제시하고 있는데,
- 재설치
- npm 기본 디렉토리 변경.
1번의 경우로 해결되면 가장 깔끔할 것 같은데, 제 경우는 해결되지 않았고, 2번에서 안내된 대로 기본 디렉토리를 변경함으로 해결했습니다. ( 2번의 방법은 윈도우에서 해결할 수 없다고 하는데, 윈도우에서는 이런일이 발생하지 않을 것 같습니다. )
2번으로 해결한 이후에 얻은 장점이 하나 더 있는데, 바로 sudo 를 붙이지 않아도 된다는 거였습니다. 문제는 해결했지만, 왜 갑자기 이런 증상이 생긴지 파악하지 못한 것이 마음에 걸립니다.
참고 :
gyp WARN EACCES user "root" does not have permission to access the dev dir
Trying to sudo npm install protractor -g and the same notorious error/warning again (googled to no avail): gyp WARN EACCES user "root" does not have permission to access the dev dir "/Users/
stackoverflow.com
https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally
Resolving EACCES permissions errors when installing packages globally | npm Documentation
If you see an EACCES error when you try to install a package globally, you can either: Reinstall npm with a node version manager (recommended), or Manually change npm’s default directory Reinstall npm with a node version manager This is the best way to a
docs.npmjs.com