오류 : EACCES : 권한이 거부되었습니다. '/ usr / local / lib / node_modules'액세스에 응답
오류의 원인은 무엇입니까 Error: EACCES: permission denied, access '/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! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/node_modules' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/macbookmd101/.npm/_logs/2018-02-21T16_26_08_421Z-debug.log
파일 사용 권한을 변경하십시오.
먼저 디렉토리를 소유 한 사람을 확인하십시오.
ls -la /usr/local/lib/node_modules
node_module 폴더가 root에 의해 소유되어 있기 때문에 액세스를 거부하고 있습니다.
drwxr-xr-x 3 root wheel 102 Jun 24 23:24 node_modules
따라서 루트는 사용자로 변경하고 현재 사용자를 확인하기 위해 먼저 아래 명령을 실행하여 변경해야합니다 . OS X의 명령 줄을 통해 활성 사용자의 이름을 얻으려면 어떻게합니까?
id -un
또는
whoami
그런 다음 소유자를 변경하십시오.
sudo chown -R [owner]:[owner] /usr/local/lib/node_modules
또는
sudo chown -R ownerName: /usr/local/lib/node_modules
또는
sudo chown -R $USER /usr/local/lib/node_modules
시도중인 명령 앞에 sudo 를 추가하십시오 .
이처럼 : sudo npm install
Linux / UNIX에서 명령에 sudo를 사용하면 일반적으로 권한이 수퍼 유저 레벨로 높아집니다. Windows에서 수퍼 유저 계정은 일반적으로 '관리자'라고합니다. Linux / Unix에서 수퍼 유저 계정의 이름은 일반적으로 'root'입니다.
루트 사용자는 컴퓨터의 거의 모든 파일에 액세스, 수정 또는 삭제할 수있는 권한이 있습니다. 일반 사용자 계정은 더 적은 수의 파일에 액세스, 수정 또는 삭제할 수 있습니다. 일반 계정에 대한 제한은 컴퓨터를 무단 또는 유해한 프로그램이나 사용자로부터 보호합니다. 일부 프로세스에서는 일반적으로 액세스 권한이없는 파일 또는 폴더에 대한 작업을 수행해야합니다. 모든 사람이 액세스 할 수있는 프로그램을 설치하는 것이 이러한 작업 중 하나입니다.
귀하의 경우 sudo를 사용하여 설치 명령을 실행하면 수퍼 유저의 권한이 부여되고 일반 사용자가 수정할 권한이없는 파일을 수정할 수 있습니다.
/ local / lib의 소유자에게 USER를 추가하기 만하면됩니다.
sudo chown -R $USER /usr/local/lib
권한 오류 가능성을 최소화하기 위해 다른 디렉토리를 사용하도록 npm을 구성 할 수 있습니다. 이 예에서는 홈 디렉토리에 숨겨진 디렉토리를 작성하고 사용합니다.
컴퓨터를 백업하십시오. 명령 행의 홈 디렉토리에서 글로벌 설치를위한 디렉토리를 작성 mkdir ~/.npm-global
하십시오. 새 디렉토리 경로를 사용하도록 npm 구성 : npm config set prefix '~/.npm-global'
선호하는 텍스트 편집기에서 ~/.profile
파일을 열거 나 작성 하고이 행을 추가하십시오. export PATH=~/.npm-global/bin:$PATH
명령 행에서 시스템을 갱신하십시오. 변수 : source ~/.profile
새 구성을 테스트하려면 sudo를 사용하지 않고 패키지를 전체적으로 설치하십시오.
ubuntu에 전역 패키지를 설치하는 동안 usr/bin
폴더에 쓸 때 특별한 쓰기 권한이 필요 합니다. 보안상의 이유입니다. 따라서 전역 패키지를 설치할 때마다 다음을 사용하십시오.
sudo npm install -g [package-name]
구체적인 경우에는 다음과 같습니다.
sudo npm install -g typescript
권한 문제가 발생한 것 같습니다. 당신이 설치하는 경우 npm-packages
다음 당신은 가능한 점점 수 있음을 EACCES
세계적으로 패키지를 설치하려고 오류가 발생했습니다. 즉, npm
전역 패키지 및 명령을 저장하는 데 사용 하는 디렉토리에 쓸 수있는 권한이 없습니다 .
명령을 실행 해보십시오 : sudo chmod u+x -R 775 ~/.npm
및 sudo chown $USER -R ~/.npm
또는 당신은 어떤 실행할 수 npm
와 명령 sudo
문제 해결을 얻어야한다.
npm-package
로컬로 설치하는 경우 로컬 프로젝트 디렉토리에 있어야하며 sudo npm install <pkg-name>
명령을 실행 하여 필요한 패키지를 설치할 수 있습니다 . 사용 목적은 sudo
소유자 권한을 변경하여 현재 사용자에게 npm
명령 을 실행할 권한을 부여하는 것 입니다.
https://docs.npmjs.com/getting-started/fixing-npm-permissions를 살펴 보는 것이 좋습니다.
/ usr / local 아래의 모든 디렉토리의 소유자를 변경하는 모든 응답에주의하십시오 기본적으로 리눅스 시스템을 망쳐 놓지 마십시오!
가장 좋은 방법은 자신의 폴더를 사용하여 모든 전역 패키지를 찾는 것입니다. https://www.competa.com/blog/how-to-run-npm-without-sudo/
sudo 사용자 로 설치하려면이 명령을 사용하십시오 npm
.
sudo npm install -g create-react-app
npm 대신 -g create-react-a pp 설치하십시오.
Mac에서이 문제가 발생하는 경우 이 단계를 따르세요
아래 명령을 사용 하여이 파일의 소유자를 먼저 확인하십시오.
ls -la /usr/local/lib/node_modules
아래 파일 중 하나가 아래에 있습니다.
drwxr-xr-x 3 루트 휠 768 May 29 02:21 node_modules
have you notice that above file is own by root, for make changes inside for you need to change owner ship of path.
you can use check who is current user by this command
id -un (in my case user is yamsol)
and then you can change by calling this command (just replace your user name with ownerName)
sudo chown -R ownerName: /usr/local/lib/node_modules
in my case as you know user is "yamsol" i will call this command in this way
sudo chown -R yamsol: /usr/local/lib/node_modules
thats it.
I was trying to install react expo and apart from sudo I had to add --unsafe-perm
like this. This resolves my Issue
sudo npm install -g expo-cli --unsafe-perm
Seems like you tried to install a npm package globally rather than locally, as the man npm install
describes:
The -g or --global argument will cause npm to install the package globally rather than locally.
Generally, when you are setting up a npm project (among many others that you could have), it's not a good idea to install packages on Node.js global modules (/usr/local/lib/node_modules), as your the debug log suggested.
Instead of using -g
, use --save
, which will automatically save the package as a dependency for your package.json
file:
Like this:
$ npm install express-generator --save
$ cat package.json
{
"name": "first_app_generator",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "ivanleoncz",
"license": "MIT",
"dependencies": {
"express-generator": "^4.16.0"
}
}
But as the other answers mentioned, if you're going to use -g
, you have to use sudo
(if your user has sudo privileges: see /etc/sudoers) when performing npm install express-generator -g
, but indeed, it's not a good idea, possibly causing permission problems.
NOTICE
There are instructions for installing express-generator
with -g
option, in order to have the script express-cli.js
available on the system path, but you can use the locally installed script as well, located at the node_modules
if your npm project:
$ ./node_modules/express-generator/bin/express-cli.js --view=pug myapp
If a message like /usr/bin/env: ‘node’: No such file or directory shows up, install
nodejs-legacy
(Debian/Ubuntu)
IMHO, using -g
(also using sudo
) is like hic sunt dracones, if you are unsure of the consequences.
For further information:
Simply you can change the owner or just use sudo before you command like this
sudo chown -R [owner]:[owner] /usr/local/lib/node_modules
(change owner)
or
sudo npm install -g json-server
that's it.
You need the permission of superuser levels to install React. In Linux/Unix the superuser account is generally named 'root'.
To get superuser privilege just run the following command on your terminal:
sudo -i
and then simply run the command to install React:
npm install -g create-react-app
For linux / ubuntu if the command
npm install -g <package_name>
npm WARN deprecated superagent@4.1.0: Please note that v5.0.1+ of superagent removes User-Agent header by default, therefore you may need to add it yourself (e.g. GitHub blocks requests without a User-Agent header). This notice will go away with v5.0.2+ once it is released.
npm ERR! path ../lib/node_modules/<package_name>/bin/..
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall symlink
npm ERR! Error: EACCES: permission denied, symlink '../lib/node_modules
/<package_name>/bin/..' -> '/usr/local/bin/<package_name>'
npm ERR! { [Error: EACCES: permission denied, symlink '../lib/node_modules/<package_name>/bin/..' -> '/usr/local/bin/<package_name>']
npm ERR! cause:
npm ERR! { Error: EACCES: permission denied, symlink '../lib/node_modules/<package_name>/bin/..' -> '/usr/local/bin/<package_name>'
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'symlink',
npm ERR! path: '../lib/node_modules/<package_name>/bin/..',
npm ERR! dest: '/usr/local/bin/ionic' },
npm ERR! stack:
npm ERR! 'Error: EACCES: permission denied, symlink \'../lib/node_modules/ionic/bin/ionic\' -> \'/usr/local/bin/ionic\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'symlink',
npm ERR! path: '../lib/node_modules/<package-name>/bin/<package-name>',
npm ERR! dest: '/usr/local/bin/<package-name>' }
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).
npm ERR! A complete log of this run can be found in:
npm ERR! /home/User/.npm/_logs/2019-07-29T01_20_10_566Z-debug.log
Fix : Install with root permissions
sudo npm install <package_name> -g
I have used sudo, but it didnt solve the problem, I have fixed the issue by changing the node_modules folder permission,
sudo chmod -R 777 node_modules
If you want you can replace 777 with any other code if you dont set the permission for all user/group.
I was able to get rid of this issue by installing nvm
, then setting node to latest version.
- Install
nvm
usingcurl
(for latest version go to nvm.sh)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
- List available node versions
nvm ls
v10.12.0
default -> v10.12 (-> v10.12.0)
node -> stable (-> v10.12.0) (default)
stable -> 10.12 (-> v10.12.0)
…
- Choose which version of node to use
nvm use v10.12
nvm is not compatible with the npm config "prefix" option: currently set to ""
- Run this to unset the option:
nvm use --delete-prefix v10.12.0
After following the commands above, you will be able to install react/angular in Ubuntu.
I find similar problem with webpack module. My solution - remove node_modules folder rm -rf node_modules and run npm i without sudo - installation should work.
Helped only this:
sudo chown -R ownerName: /usr/local/lib/node_modules
'Programming' 카테고리의 다른 글
안드로이드에서 콜백을 정의하는 방법? (0) | 2020.06.12 |
---|---|
POST 양식을 제출 한 후 결과를 보여주는 새 창을 엽니 다 (0) | 2020.06.12 |
PostgreSQL에서 뷰의 CREATE VIEW 코드를 보는 방법은 무엇입니까? (0) | 2020.06.12 |
Visual Studio에서 생성자를 만드는 코드 조각 또는 바로 가기 (0) | 2020.06.12 |
Java에서 참조로 문자열 전달? (0) | 2020.06.12 |