Skip to content

Instantly share code, notes, and snippets.

@dazecoop
Created November 10, 2021 10:19
Show Gist options
  • Save dazecoop/f19c7387774240f96fcf66a95ce282ea to your computer and use it in GitHub Desktop.
Save dazecoop/f19c7387774240f96fcf66a95ce282ea to your computer and use it in GitHub Desktop.
Configure NPM to use different directory

Configure NPM to use different directory

Via stackoverflow and docs.npmjs.com


On the command line, in your home directory, create a directory for global installations:

mkdir ~/.npm-global

Configure npm to use the new directory path:

npm config set prefix '~/.npm-global'

In your preferred text editor, open or create a

~/.profile

file and add this line:

export PATH=~/.npm-global/bin:$PATH

On the command line, update your system variables:

source ~/.profile

To test your new configuration, install a package globally without using sudo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment