Configure NPM for global user without sudo on Mac OS

Using ‘sudo’ with NPM is a no-no, as it can cause all kinds of havoc with file permissions. You can specify a default directory for globally installed packages and thus absolve yourself of sudo chaos.

Create a directory for global packages with Terminal.app:

Tell npm where to store globally installed packages:

3. Add the following to .bash_profile in your home directory:

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.