Created
April 25, 2017 10:39
-
-
Save NejcZdovc/4da9ce4464b119aa89666a6c70dbe630 to your computer and use it in GitHub Desktop.
Npm without sudo
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
# Source https://johnpapa.net/how-to-use-npm-global-without-sudo-on-osx/ | |
# ---------------------- | |
# install brew | |
# clean instal | |
brew install node --without-npm | |
mkdir "${HOME}/.npm-packages" | |
echo NPM_PACKAGES="${HOME}/.npm-packages" >> ${HOME}/.bashrc | |
echo prefix=${HOME}/.npm-packages >> ${HOME}/.npmrc | |
curl -L https://www.npmjs.org/install.sh | sh | |
echo NODE_PATH=\"\$NPM_PACKAGES/lib/node_modules:\$NODE_PATH\" >> ${HOME}/.bashrc | |
echo PATH=\"\$NPM_PACKAGES/bin:\$PATH\" >> ${HOME}/.bashrc | |
echo source "~/.bashrc" >> ${HOME}/.bash_profile | |
source ~/.bashrc | |
# ------------------------------ | |
# upgrade | |
# Remove old npm | |
sudo rm -rf /usr/local/lib/node_modules | |
sudo rm -rf ~/.npm | |
brew uninstall node | |
# install | |
rm -rf "${HOME}/.npm-packages" | |
mkdir "${HOME}/.npm-packages" | |
brew install node --without-npm | |
curl -L https://www.npmjs.org/install.sh | sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment