Last active
March 27, 2019 11:46
-
-
Save aamnah/2aff3e5e87674af7ec8a220f585c4d14 to your computer and use it in GitHub Desktop.
Fix npm permissions for running global 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
#!/bin/bash | |
# source: | |
# https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally | |
fix_npm_permissions () { | |
# create a new directory for installing npm pacages | |
mkdir ${HOME}/.npm-global | |
# Configure npm to use the new directory path: | |
npm config set prefix '~/.npm-global' | |
# Update PATH in ~/.bashrc | |
echo -e " | |
# changing npm global install folder to fix permission errors | |
PATH=\"${HOME}/.npm-global/bin:$PATH\"" >> ${HOME}/.bashrc | |
# On the command line, update your system variables: | |
source ${HOME}/.bashrc | |
} | |
fix_npm_permissions |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment