Last active
March 26, 2016 16:33
-
-
Save ryaninvents/d7413b40b72f026b3ee2 to your computer and use it in GitHub Desktop.
Fix npm global install
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
# This script is the **correct** way to allow installation and use | |
# of npm executables without sudo. | |
# Declare where you want your global packages installed to. | |
npm config set prefix '~/.local/share/npm' | |
# Ensure the directory exists. | |
mkdir -p ~/.local/share/npm | |
# Change `.zshrc` to `.bashrc` if appropriate, but consider instead | |
# switching to zsh. | |
SHELL_PROFILE=~/.zshrc | |
# Make sure the executables folder is in your $PATH. | |
echo 'export PATH="$HOME/.local/share/npm/bin:$PATH"' >> $SHELL_PROFILE | |
# Make sure global node modules can find their dependencies correctly (think `yo`) | |
echo 'export NODE_PATH="$NODE_PATH:$HOME/.local/share/npm/lib/node_modules"' >> $SHELL_PROFILE | |
# Make the changes take effect. | |
source $SHELL_PROFILE | |
# Now you'll have to reinstall all global modules so your user has control. | |
# Here's my general set of defaults; I may be forgetting some. | |
npm i -g npm yo gulp webpack n |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment