Skip to content
Latchkey

npx: Usage, Options & Common CI Errors

npx runs a command from a local or remote npm package without installing it globally.

npx executes a package's binary on demand. In CI its hazards are the interactive "Ok to proceed?" prompt that hangs non-TTY jobs and silent version drift when nothing is pinned.

What it does

npx resolves a binary: it prefers a locally installed one (node_modules/.bin), otherwise downloads the package temporarily and runs it. Without a pinned version it fetches the latest, which is convenient but non-reproducible. --yes suppresses the install confirmation; --no-install forces use of an already-installed binary only.

Common usage

Terminal
npx --yes prettier --check .                    # auto-confirm any download
npx prettier@3.3.2 --check .                     # pin the version (reproducible)
npx --no-install eslint .                        # fail if not already installed
npx create-vite@latest my-app -- --template react

Common errors in CI

In a non-TTY job npx prompts "Need to install the following packages ... Ok to proceed? (y)" and hangs until timeout - pass --yes (or set CI=true, which many tools honor). "npm ERR! could not determine executable to run" means the package has no bin matching the name you invoked, or the name is misspelled. Unpinned npx tool@latest changes behavior run-to-run; pin the version. npx downloads on a cache miss, adding network flakiness - prefer a devDependency + npx --no-install for hot paths.

Options

FlagWhat it does
-y / --yesSkip the install confirmation prompt
--no-installOnly use an already-installed binary
-p / --package <pkg>Specify the package providing the bin
<pkg>@<version>Pin the exact version (reproducible)

Related guides

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