September 23, 2014

Fixing NPM EACCES Error on OS X

So if you’ve installed Node using root permissions you might get an npm ERR! Error: EACCES when trying to install npm packages. This means you need to use sudo every time you want to install a package (not ideal). Apparently this is the case when you use the .pkg installer on OS X.

However there is a quick fix for this. You simply need to run the following two commands in terminal:

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

These commands give the current user ownership of the “npm” and “node_modules” directories, allowing you to use npm without sudo. Sweet.

Looking for more?

Subscribe to my newsletter to get infrequent updates in your inbox. Or follow me on Twitter.