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