Run npm install without sudo

You can run the following commands to configure your machine to run the npm install without sudo:

sudo chown -R $(whoami) /usr/local/{lib/node_modules,bin,share}
sudo chown -R $(whoami) ~/.npm

The above command will change the owner of node_modules directories to the current user. You will be able to run the npm install command without sudo now.