Skip to content

Instantly share code, notes, and snippets.

@danilobatistaqueiroz
Created July 16, 2019 14:09
Show Gist options
  • Select an option

  • Save danilobatistaqueiroz/fe509fb0af0a01e7310202da9336889f to your computer and use it in GitHub Desktop.

Select an option

Save danilobatistaqueiroz/fe509fb0af0a01e7310202da9336889f to your computer and use it in GitHub Desktop.
running npm without root
https://www.competa.com/blog/how-to-run-npm-without-sudo/
npm config set prefix ~/.npm
# open your .bashrc (Linux) or .bash_profile (Mac) file for editing:
nano ~/.bashrc # for Linux
# or...
nano ~/.bash_profile # for Mac if you haven't created a .bashrc file
# add these lines:
export PATH="$PATH:$HOME/npm/bin"
export NODE_PATH="$NODE_PATH:$HOME/npm/lib/node_modules"
# save the file and then enter this command to make the changes take effect:
. ~/.bashrc
# or...
. ~/.bash_profile
# optionally check to see if anything is owned by root:
ls -la ~/.npm
# take ownership of everything in your ~/.npm directory (must be run with sudo):
sudo chown -R $USER:`id -g -n $USER` ~/.npm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment