Skip to content
Latchkey

npm exec & npx: Usage, Options & Common Errors

Run a package binary without a global install.

npm exec (and its alias npx) runs a command from a local or remote package, fetching it on demand if it is not already installed - ideal for one-off tools in CI.

What it does

Resolves the binary from node_modules/.bin if present; otherwise downloads the package to a temporary cache and runs it. npx <pkg> is shorthand for npm exec -- <pkg>. In CI it prompts before installing a missing package unless you pass --yes.

Common usage

Terminal
npx tsc --noEmit            # run local typescript
npm exec -- eslint .        # run local eslint
npx --yes cowsay hi         # auto-confirm a remote install (CI-safe)
npx create-react-app@latest my-app

Common CI error: could not determine executable

CI fails with "npm error could not determine executable to run". The package name and its binary name differ, or the package is not installed. Specify the binary explicitly with --package, and pass --yes so npx does not stall on a confirmation prompt in CI.

Terminal
npx --yes --package=typescript tsc --version

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →