Skip to content

Instantly share code, notes, and snippets.

@mishailovic
Created January 5, 2022 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mishailovic/aa7d703d81112c4b71116a1356762ff0 to your computer and use it in GitHub Desktop.
Save mishailovic/aa7d703d81112c4b71116a1356762ff0 to your computer and use it in GitHub Desktop.

// https://stackoverflow.com/questions/48910876/error-eacces-permission-denied-access-usr-local-lib-node-modules

Back up your computer. 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