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

Solution 1:

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.

Solution 2:

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

Solution 3:

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

Solution 4:

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

is sufficient.

Solution 5:

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