If you have gotten this error or similar file permission issue on mac you can follow the steps listed in this gist to resolve the problem with node & npm. With this method of installing node you can eliminate using sudo for npm. Please follow along.
For mac here is how node, npm should be installed using nvm. This is the official nodejs.org recommendation for macbook pro. With this approach it eliminates the need of using sudo for npm and file permission issues are automatically addressed.