Categories
JavaScript Answers

How to fix Permission denied when installing npm modules in OSX?

Spread the love

To fix Permission denied when installing npm modules in OSX, we change the permission of the node_modules directory.

For instance, we run

sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}

to run chown to get the user with whoami and then set the node_modules, bin, and share directories’ owner to the current user.

And then we install packages with

sudo npm install

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *