npx: Run Tools Without Installing
npx runs package binaries, downloading on demand if not installed.
npx is handy for one-off tools, but in CI an unpinned npx fetch is non-deterministic and a minor supply-chain risk.
Common usage
npx <pkg> [args]- run a CLInpx --yes <pkg>- skip the install promptnpx --no-install <cmd>- only use localnpx <pkg>@<version>- pin the version
Example in CI
Pin the version when fetching on demand.
shell
npx --yes prettier@3 --check .In CI
Prefer npx --no-install so it uses the pinned devDependency, or pin pkg@version. Unpinned npx pkg resolves to latest at runtime.
Key takeaways
- Pin
pkg@versionor use--no-install. - Unpinned npx resolves to latest at runtime.
--yesavoids the interactive prompt.