run

npm exec (npx)

Runs a package's binary from a local install, the cache, or on-the-fly from the registry without a global install. `npx` is the shell-friendly shim; both are equivalent in npm 10+.

npm exec -- <pkg>[@<version>] [args] | npx <pkg> [args]

Common flags

Flag Purpose
--package <pkg> (-p) Specify the package to fetch when the bin name differs
--yes (-y) Auto-accept installing missing packages
--no Refuse to install a missing package
--call <cmd> (-c) Run an arbitrary shell command with node_modules/.bin on PATH
--workspace <name> (-w) Execute inside a specific workspace

Examples

npx create-vite my-app

Run a create-* package one-off, no global install

npm exec -- eslint src/

Same as `npx eslint` — uses the local devDependency

npx -p typescript@5 -c 'tsc --version'

Pin a specific version for a one-shot call

Gotcha

npx prefers the local node_modules/.bin over the registry, so a stale local install can shadow the version you meant. Use `-p pkg@version` to force a specific remote version or a scoped bin name.

Related commands

← All npm commands · npm vs pnpm vs Yarn · Fix Node OOM