Will & Skill Developers

Will & Skill Developers


Thoughts, snippets and ideas from the team at Will & Skill AB, Stockholm.

Faisal M
Author

“The mind is not a vessel to be filled, but a fire to be kindled.” ― Plutarch

Share


Tags


avrt

How to fix EACCES errors with NPM on MacOS

Faisal MFaisal M

There are times when You get an ugly EACCES error message from NPM when You try to install an NPM package globally on Your Mac by running npm install -g <PACKAGE_NAME> or npm uninstall -g <PACKAGE_NAME>.

This is how it looks on my terminal:

Screenshot-2019-11-11-at-15.28.41

Faisals-Mac:Code faisal$ npm uninstall -g react-native-cli
/usr/local/lib/node_modules/react-native-cli/node_modules/winston/node_modules
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules/react-native-cli/node_modules/ansi-styles
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules/react-native-cli/node_modules/ansi-styles'
npm ERR!  { [Error: EACCES: permission denied, access '/usr/local/lib/node_modules/react-native-cli/node_modules/ansi-styles']
npm ERR!   stack:
npm ERR!    'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules/react-native-cli/node_modules/ansi-styles\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path:
npm ERR!    '/usr/local/lib/node_modules/react-native-cli/node_modules/ansi-styles' }
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.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/faisal/.npm/_logs/2019-11-11T14_25_30_203Z-debug.log

The issue that is causing this is related to the fact that the folder NPM is trying to access/write to is not owned by the user that is executing the command

The run the commands stated below and You should be good to go!

sudo chown -R `whoami` ~/.npm
sudo chown -R `whoami` /usr/local/lib/node_modules

Try running npm install -g ... or npm uninstall -g ... without sudo and it should run without errors.

Faisal M
Author

Faisal M

“The mind is not a vessel to be filled, but a fire to be kindled.” ― Plutarch

View Comments