Skip to content

Instantly share code, notes, and snippets.

@dylansmith
Created January 12, 2015 10:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dylansmith/e5e0b8df1c86bc083ec0 to your computer and use it in GitHub Desktop.
Save dylansmith/e5e0b8df1c86bc083ec0 to your computer and use it in GitHub Desktop.
Configure npm to install global modules to userspace (set npm prefix to ~/npm)
#!/bin/bash
DIR=~/npm
if [[ ! -e $DIR ]]; then
mkdir $DIR
elif [[ ! -d $DIR ]]; then
echo "$DIR exists but is not a directory" 1>&2
exit 1
fi
npm config set prefix $DIR
echo "# add $DIR/bin to path" >> ~/.bash_profile
echo "export PATH=$DIR/bin:$PATH" >> ~/.bash_profile
source ~/.bash_profile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment