Created
January 12, 2015 10:50
-
-
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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