npx Explained
What npx does, with an example.
Published November 11, 2026
npx runs a package binary without installing it globally: it uses a local node_modules/.bin copy if present, otherwise downloads the package temporarily from the registry.
How it works
It is ideal for one-off tools and project scaffolding such as npx create-react-app or npx prettier --check . and ensures you use the project's local version.
Try it
npx cowsay hello
(downloads cowsay temporarily)
npx tsc --version
Practical examples
Run a local tool
npx eslint srcRun once without installing
npx create-vite@latest my-appPin a version
npx prettier@3.3.0 --check .Skip prompts
npx --yes cowsay helloCommon mistakes
- Running unknown packages without checking them.
- Expecting npx to cache forever.
- Version surprises (use a pinned version).
Key takeaways
- npx runs a package binary without installing it globally: it uses a local node_modules/.bin copy if present, otherwise downloads the package temporarily from the registry.
- Run npm help <command> for every option.
- Commit package-lock.json.
FAQ
npx vs npm run?
npm run runs package.json scripts; npx runs package binaries directly.
Does this work with yarn or pnpm?
They have equivalents with similar commands.