Skip to content

Instantly share code, notes, and snippets.

@amsryq
Created March 31, 2026 18:32
Show Gist options
  • Select an option

  • Save amsryq/020c1b36514f0d7b872056d2748e8a2a to your computer and use it in GitHub Desktop.

Select an option

Save amsryq/020c1b36514f0d7b872056d2748e8a2a to your computer and use it in GitHub Desktop.
Map `npm` to `pnpm` for global installation
npm() {
local cmd="$1"
shift
if [[ " $* " == *" -g "* || " $* " == *" --global "* ]]; then
case "$cmd" in
install|i) command pnpm add -g "${@/-g/}" "${@/--global/}"; return ;;
update|up|upgrade) command pnpm update -g "${@/-g/}" "${@/--global/}"; return ;;
uninstall|remove|rm) command pnpm remove -g "${@/-g/}" "${@/--global/}"; return ;;
esac
fi
command npm "$cmd" "$@"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment