Last active
April 30, 2016 22:36
-
-
Save gavinengel/1842179837823dc25730 to your computer and use it in GitHub Desktop.
sudoless-npm.sh
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/sh | |
# Place npm packages in your home folder without using sudo | |
# The lazy approach to installing cli npm programs requires sudo (root) access: | |
# $ sudo npm install -g somenpmpackage | |
# Of course, I do not recommend installing npm packages with sudo unless it's required. | |
# This is how I install CLI tools from npm without sudo: | |
# $ lib | |
# $ npm install --save somenpmpackage | |
# add to end of ~/.bash_profile or ~/.zshrc so your can use: `$ lib` | |
if [[ ! $PATH =~ .*/bin/node/lib/node_modules/.bin* ]]; then export PATH="$HOME/bin/node/lib/node_modules/.bin:$PATH";fi; | |
alias lib="cd $HOME/bin/node/lib/; ll;" | |
# initial setup (do this stuff once) | |
mkdir -p ~/bin/node/lib/; | |
cd ~/bin/node/lib/; | |
npm init -y; # if npm not found, try: /usr/bin/npm init -y; /usr/bin/npm i npm; | |
# exceptions that need to be installed with sudo: phantom? | |
# TODO incorporate $(which npm) as if/then alias for new installs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment