Skip to content

Instantly share code, notes, and snippets.

@josben
Created August 18, 2016 05:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josben/3790289766be4e1962a251028f879a48 to your computer and use it in GitHub Desktop.
Save josben/3790289766be4e1962a251028f879a48 to your computer and use it in GitHub Desktop.
How to config npm to install with global option (-g) into home dir
# ....
# ...
### First in the terminal ###
# $ NPM_PACKAGES="$HOME/.npm-packages"
# $ mkdir -p "$NPM_PACKAGES"
# $ echo "prefix = $NPM_PACKAGES" >> ~/.npmrc
### End ###
#######################
### In .bashrc file ###
#######################
# NPM packages in home directory
NPM_PACKAGES="$HOME/.npm-packages"
# Tell our environment about user-installed node tools
PATH="$NPM_PACKAGES/bin:$PATH"
# Unset manpath so we can inherit from /etc/manpath via the `manpath` command
unset MANPATH # delete if you already modified MANPATH elsewhere in your configuration
MANPATH="$NPM_PACKAGES/share/man:$(manpath)"
# Tell Node about these packages
NODE_PATH="$NPM_PACKAGES/lib/node_modules:$NODE_PATH"
### Terminal ###
# $ source ~/.bashrc
# $ npm install -g <package>
### End ###
# source: http://stackoverflow.com/questions/10081293/install-npm-into-home-directory-with-distribution-nodejs-package-ubuntu/13021677
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment