Skip to content
Latchkey

npm run: Usage, Options & Common CI Errors

Run the scripts defined in your package.json.

npm run (alias of npm run-script) executes a named script from the scripts field of package.json, with node_modules/.bin on PATH so local binaries resolve.

What it does

Looks up the named key in package.json scripts and runs it in a shell with node_modules/.bin prepended to PATH. Running npm run with no script name lists all available scripts. Arguments after -- are forwarded to the underlying command.

Common usage

Terminal
npm run build               # run the "build" script
npm run                     # list all scripts
npm run test -- --watch     # forward --watch to the test command
npm run lint --silent       # suppress npm's own log noise

Common CI error: missing script

CI fails with "npm error Missing script: \"build\"". The script name does not exist in package.json - usually a typo or a script that only lives on another branch. Run npm run to list the real script names and fix the workflow to match.

Terminal
npm run            # prints the available scripts
# then call the correct name, e.g.
npm run build:ci

Key options

FlagEffect
--Pass following args to the script
--silentSuppress npm log output
--if-presentDo not error if the script is missing
-ws, --workspacesRun the script in every workspace

Related guides

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