Fixing “Missing write access” error when using NPM

The error “Missing write access ____” generally occurs while installing the node modules as a global package. It somehow looks like this in the console.

Missing write access to /usr/local/lib/node_modules

This error is generated due to improper permission. To fix this, we need to provide the proper permissions to the directory.

Run this command.

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

Using chown command, we are providing proper permission to the logged-in user. Update the folder path if it is different.