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 binnpm 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 --noEmitIn CI
Prefer running tools from devDependencies (installed via npm ci) so versions are pinned, rather than fetching at runtime.
Key takeaways
npm execruns package binaries.- Prefer pinned local tools in CI.
--yesauto-installs a missing package.