Last active
April 25, 2016 13:08
-
-
Save jamiekurtz/31fc0b6ff55acf52f2d0 to your computer and use it in GitHub Desktop.
Configures NPM to allow global package installs without sudo, thereby avoiding the typical permissions issue with updating node packages
This file contains 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
# Install NodeJS and related on Ubuntu without requiring sudo on subsequent "npm -g" installs | |
# Went this direction when certain packages where trying to update global files owned by root... | |
# ... since the global packages were installed with sudo | |
# if using Vagrant, recommend to set "privileged: false" on the provisioning script where this code resides | |
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash - | |
sudo apt-get -y install git nodejs build-essential | |
mkdir -p ~/.npm_packages | |
npm set prefix $HOME/.npm_packages | |
echo "export NPM_PACKAGES=~/.npm_packages" >> ~/.bash_aliases | |
echo "export NODE_PATH=~/.npm_packages/lib/node_modules" >> ~/.bash_aliases | |
echo "export PATH=$PATH:~/.npm_packages/bin:~/.npm_packages/lib/node_modules" >> ~/.bash_aliases | |
source ~/.bash_aliases | |
# once this is done, you can install npm packages globally without requiring sudo... happy trails! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment