Tuesday, August 27, 2019

How To: Permission denied when installing npm modules in Mac OSX

If you installed nodejs from binary installer pkg, the node_modules folder (usually under /usr/local/lib) has ownership to be root:wheel.

What you need to do to resolve this problem is:


  • Step 1: Find the path to npm's directory:
          npm config get prefix

                      For many systems, this will be /usr/local.                    

  • Step 2: Change the owner of npm's directories to the name of the current user (your username):
sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}                       
This changes the permissions of the sub-folders used by npm and some other tools (/lib/node_modules, bin, and share).

No comments:

Post a Comment