Stop replacing
by hand.
Paste the command exactly as the README wrote it. Your shell can
intercept npx and run
pnpm dlx instead.
Step 1 - Open your shell config
Since you're using
Step 2 - Paste this function
Add the following to the bottom of .zshrc
function npx() {
pnpm dlx "$@"
}What does "$@" mean? It passes every argument you typed along to pnpm dlx. You're welcome.
Step 3 - Reload your shell
The file doesn't reload itself. Run this:
source ~/.zshrcOr just open a new terminal tab like a normal person.
Step 4 - Verify it works
npx cowsay "I use pnpm now"If a cow says it, it's true.
Too lazy? Give this to your AI
Can't be bothered to do four whole steps? Fine. This prompt is
already tailored to
Prompt
I want to set up a shell function that redirects npx to pnpm dlx. I'm using Zsh, so my shell config file is ~/.zshrc. Here's what to do: 1. Open ~/.zshrc. 2. Add the following function at the bottom of that file: function npx() { pnpm dlx "$@" } 3. Save the file. 4. Reload the config by running: source ~/.zshrc 5. Confirm the override is active by running: which npx - it should be a shell function, not a binary. Don't overthink it.