Tips and tricks

Install npm packages globally on mac without sudo

For that we will follow these steps:

1. Create a directory for global packages
mkdir ~/.npm_packages

2. Tell npm where to store globally installed packages
npm config set prefix "~/.npm_packages"

3. Ensure npm will find installed binaries and man pages

Add the following to your .bashrc / .zshrc:

NPM_PACKAGES="~/.npm_packages"

export PATH="$PATH:$NPM_PACKAGES/bin"

# Preserve MANPATH if you already defined it somewhere in your config.
# Otherwise, fall back to `manpath` so we can inherit from `/etc/manpath`.
export MANPATH="${MANPATH-$(manpath)}:$NPM_PACKAGES/share/man"

i. check config with:
npm config get

Leave a comment

Your email address will not be published

{"type":"main_options","images_arr":"'#ffffff'","bg_slideshow_time":"0","site_url":"https:\/\/digitalzoomstudio.net","theme_url":"https:\/\/digitalzoomstudio.net\/wp-content\/themes\/qucreative\/","is_customize_preview":"off","gallery_w_thumbs_autoplay_videos":"off","base_url":"https:\/\/digitalzoomstudio.net"}