On your dev machine
If you are the typical js developer who works on OS X, all you need to do is just change the owner of the node binaries
# this should solve the problem sudo chown -R MY_USER_NAME /usr/local # this may also help sudo chmod -R 777 ~/.npm
If you are working on projects and someone has already checked in a package.json run with sudo, you need to make sure the whole team changes the permissions of at the same time
# if someone has checked in a version # of package.json with the wrong permissions chmod -775 package.json
Unix purists will find this hacky; and rightly so. The proper way of doing is to create a group for everyone who should be allowed to run npm, even if it’s just you. However for a simple dev machine that is good enough.