run

npm run

Executes a script from the `scripts` block of package.json in a shell where node_modules/.bin is on PATH. Alias: `run-script`; running `npm run` with no arg lists every available script.

npm run <script> [-- <args>]

Common flags

Flag Purpose
-- Separator; everything after it is forwarded verbatim to the underlying script
--if-present Silently succeed when the script is not defined
--workspace <name> (-w) Run inside a specific workspace
--workspaces (-ws) Run the script in every workspace that defines it
--silent (-s) Suppress npm's own log framing around the script

Examples

npm run build

Run the "build" script from package.json

npm run test -- --watch

Forward --watch to the underlying test runner

npm run lint -ws --if-present

Run lint in every workspace that has it

Gotcha

Arguments before `--` are consumed by npm itself; put runner flags after `--` or they will be silently dropped. Only `start`, `stop`, `test`, and `restart` have shortcut verbs — every other script requires `run`.

Related commands

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