Skip to content
Latchkey

npm exec: Run Package Binaries

npm exec runs a binary provided by a package without a global install.

npm exec is the modern form of npx for running CLIs that live in your dependencies or fetching one on demand.

Common usage

  • npm exec -- <cmd> [args] - run a local bin
  • npm exec --yes -- <pkg> - auto-fetch if missing
  • --call - run an inline command

Example in CI

Run a project-local tool deterministically.

shell
npm exec -- tsc --noEmit

In CI

Prefer running tools from devDependencies (installed via npm ci) so versions are pinned, rather than fetching at runtime.

Key takeaways

  • npm exec runs package binaries.
  • Prefer pinned local tools in CI.
  • --yes auto-installs a missing package.

Related guides

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