Skip to content
Latchkey

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 CLI
  • npx --yes <pkg> - skip the install prompt
  • npx --no-install <cmd> - only use local
  • npx <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@version or use --no-install.
  • Unpinned npx resolves to latest at runtime.
  • --yes avoids the interactive prompt.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →