Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: EACCES: permission denied when trying to install ESLint using npm

People also ask

How do I fix npm install error?

If your npm is broken: On Mac or Linux, reinstall npm. Windows: If you're on Windows and you have a broken installation, the easiest thing to do is to reinstall node from the official installer (see this note about installing the latest stable version).


Use --unsafe-perm=true and --allow-root flags with npm install like below:-

sudo npm install -g eslint --unsafe-perm=true --allow-root

it worked like charm for me.


This problem is well documented in the npm docs: Fixing npm permissions.

You have 2 solutions available:

Option 1: Change npm's default directory to a hidden directory in your home folder

mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
export PATH=~/.npm-global/bin:$PATH
source ~/.profile

Option 2: Use a package manager that takes care of this for you

brew install node

Running the following command solved the issue for me while installing my packages.json :

 sudo npm install --unsafe-perm=true --allow-root

To install only the package which caused the issue:

  sudo npm install -g --unsafe-perm=true --allow-root eslint

sudo npm install -g --unsafe-perm=true eslint

is sufficient.


Use sudo before tns and it is work for me

Example:

sudo tns create Tekmo --template tns-template-hello-world

if I have used sudo then not found error like to create postinstall.js

Error: EACCES: permission denied


you can login as root using sudo su. First run the command sudo su on your terminal, then give your login password. Finally execute your expected command npm install -g eslint. It works for me.