programing

MAC에서 /usr/local/lib/node_modules에 대한 쓰기 액세스가 누락됨

sourcejob 2023. 8. 7. 22:31
반응형

MAC에서 /usr/local/lib/node_modules에 대한 쓰기 액세스가 누락됨

Angular CLI를 설치하려고 하는데 /usr/local/lib/node_modules에 대한 쓰기 액세스가 누락되어 표시됩니다. Machine에서 수정하려면 시간이 걸릴 수 있지만 정확한 답변을 얻지 못합니다.

 npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!  { [Error: EACCES: permission denied, access '/usr/local/lib/node_modules']
npm ERR!   stack:
npm ERR!    'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules' }
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 (though this is not recommended).

터미널 창에서 다음 명령을 실행합니다.

sudo chown -R $USER ~/.npm
sudo chown -R $USER /usr/lib/node_modules
sudo chown -R $USER /usr/local/lib/node_modules

이 문제가 있었습니다. 모든 글로벌 설치에서 sudo에 전화하여 해결할 수 있었습니다.저는 그것에 대해 괜찮지 않았습니다.

는 npm 패키지를 sudo 없이 설치할 수 있도록 npm 패키지 설치 조언을 따랐습니다.

sudo chown -R $(whoami) /usr/local/bin /usr/local/lib /usr/local/include /usr/local/share

@jeduard의 대답은 나에게 통하지 않았습니다.

문제를 해결하는 가장 좋은 방법npm install -g문제:

https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally

이렇게 하면 다음을 사용할 필요가 없습니다.SUDO또는change permissions.

견적:

  1. 컴퓨터를 백업합니다.

  2. 명령줄의 홈 디렉토리에 글로벌 설치를 위한 디렉토리를 생성합니다.

    mkdir ~/.npm-global
    
  3. 새 디렉터리 경로를 사용하도록 npm을 구성합니다.

    npm config set prefix '~/.npm-global'
    
  4. 원하는 텍스트 편집기에서 다음을 열거나 만듭니다.~/.profile파일을 작성하고 다음 행을 추가합니다.

    export PATH=~/.npm-global/bin:$PATH
    
  5. 명령줄에서 시스템 변수를 업데이트합니다.

    source ~/.profile
    

추가 중sudo이전에npm install내 하루를 구했어요:

sudo npm install -g @angular/cli

시스템 암호를 입력하면 설치가 원활하게 완료됩니다.

Attaching Screenshot

같은 문제입니다.터미널을 사용하는 대신 https://nodejs.org/en/download/ 을 통해 최신 버전의 노드를 다시 설치했습니다.이를 통해 문제가 해결되었습니다.

React를 설치하려고 할 때 비슷한 문제가 발생했습니다. 권한이 거부되는 문제입니다.

여기서 SUDO는 허용된 사용자가 슈퍼유저 또는 다른 사용자로서 명령을 실행할 수 있습니다.Windows에서 "관리자 권한으로 실행"을 생각해 보십시오.다음 명령을 입력하면 필요한 모든 폴더에 액세스할 수 있으며 적절한 권한 상승으로 액세스할 수 있습니다.

sudo chown -R $(whoami) /usr/local/bin /usr/local/lib /usr/local/include /usr/local/share

이는 Dimitri의 답변에도 나타나 있습니다. https://stackoverflow.com/a/60791736/3803726

macOS의 경우 실행을 시도합니다.

sudo chown -R $USER ~/.npm
sudo chown -R $USER /usr/local/lib/node_modules
sudo chown -R $USER /usr/local/bin/

그래도 작동하지 않으면 npm install 명령에 sudo를 추가해야 할 수 있습니다.

NPM 모듈을 전체적으로 설치하는 것이 차단된 경우(예: 일부 회사 노트북에서), 모든 NPM 모듈을 로컬 폴더 한 곳에 설치한 다음 node_modules/.bin/ 경로를 PATH 환경에 추가할 수 있습니다.

저도 같은 문제가 있었습니다.
에 이 합니다.

sudo nautilus

그런 다음 루트 액세스 권한을 가진 다른 파일 관리자를 엽니다.

enter image description here

그 타입 이후에.

    sudo apt install nodejs 
    sudo apt install npm 
    sudo npm install -g npm@latest
    sudo npm install -g @angular/cli
    ng --version

언급URL : https://stackoverflow.com/questions/54802330/missing-write-access-in-mac-to-usr-local-lib-node-modules

반응형