Install npm packages without sudo
If you run the following command to install npm package:
and get an access error, you might be tempted to run this command with sudo and it'll work, but it's not a right way for sure. Npm modules should be installed without sudo. To fix the problem you need to do two things:
1) Set yourself as an owner of ~/.npm directory, like this:
and if error persisits, set yourself as an owner /usr/local/lib/node_modules directory too, like this:
Now you can install npm packages without sudo.