From 75fb0068a043d2beece5387ce540351f088beccf Mon Sep 17 00:00:00 2001 From: George Rawlinson Date: Sun, 22 Aug 2021 19:13:56 +1200 Subject: [PATCH] feat(plugin): add npm --- plugins/npm | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 plugins/npm diff --git a/plugins/npm b/plugins/npm new file mode 100644 index 0000000..6398710 --- /dev/null +++ b/plugins/npm @@ -0,0 +1,24 @@ +# +# npm +# + +# Install NPM packages globally without requiring sudo +# https://github.com/sindresorhus/guides/blob/master/npm-global-without-sudo.md +if command -v npm &> /dev/null; then + + # Use XDG dirs + export NPM_CONFIG_USERCONFIG="$XDG_CONFIG_HOME/npm/config" + export NPM_CONFIG_CACHE="$XDG_CACHE_HOME/npm" + export NPM_CONFIG_TMP="$XDG_RUNTIME_DIR/npm" + export NPM_CONFIG_PREFIX="$XDG_DATA_HOME/npm" + + # add npm binary directory to PATH + path+=("$NPM_CONFIG_PREFIX/bin") + export PATH + + # Rare, but some npm packages install man pages... + MANPATH="$NPM_CONFIG_PREFIX/share/man:$(manpath)" + export MANPATH +fi + +# vim: ft=zsh expandtab tabstop=2 shiftwidth=2