Snippet - Fixing npm permissions

3 years ago

Have you ever seen this dialog after trying to update npm? This usually means something happened to your directory permissions where npm installed. There can be a whole host of reasons why this could happen including installing Node with sudo. If your using a company asset, it could likely be some corporate crapware messing with your file system.

npm error

Fortunately, there is an easy fix:

Code

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