Skip to content

Missing write access to /usr/local/lib/node_modules – npm error – How to fix?

When you are setting up npm packages for the first time for a Node JS project, you might face a strange error – Missing write access to /usr/local/lib/node_modules. This error occurs when you are globaly installing npm packages using the command npm install -g <package>

This is a permission error that hints you do not have permissions to write to the folder – /usr/local/lib/node_modules.

To fix this error, you need to change ownership of the folder to your user account.

sudo chown -R $USER /usr/local/lib/node_modules

This command changes the owner of the folder to your user account so that you can safely install npm packages globally.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.