By default npm on MacOS tries to install global modules (npm install -g somemodule) to /usr/local/lib/node_modules and you get this error:
Error: EACCES: permission denied, access \'/usr/local/lib/node_modules\'
The npm docs here have a couple of steps to avoid this by telling npm to install to a location where you have have access to:
mkdir ~/.npm-global npm config set prefix '~/.npm-global'
Edit your .profile or .bash_profile to add the new location to your PATH:
Now you should be all set!
2 Replies to “Fixing npm global install permissions on MacOS”