A CLI tool to run multiple npm-scripts in parallel or sequentially, with support for retrying failed tasks.
npm install npm-run-all-next


A modern, drop-in task runner for npm, pnpm, and yarn.
It lets you run multiple npm scripts in series or in parallel, with smart features for real-world CI/CD and monorepos:
- robust retries for flaky tasks
- intelligent parallelization / load balancing
- human-friendly summary tables
- cross-platform behavior (Windows / macOS / Linux)
- usable both as CLI (run-s, run-p, npm-run-all) and as a Node API
npm-run-all-next is a modern evolution of npm-run-all, built for todayβs workflows:
- π --retries
Automatically retry flaky tasks without rewriting scripts.
- βοΈ --balancer
Parallel tasks are scheduled using historical runtime data, so long-running tasks are started earlier and total build time goes down.
- π --print-summary-table
Get a final report with exit code, retries, and duration for each task.
- π --tasks-file
Load task lists from an external file (JSON/JS), so your package.json doesnβt become unreadable.
- π§΅ Familiar commands
run-s, run-p, and npm-run-all are included and cross-platform.
- π§ͺ First-class Node API
Run tasks programmatically with runTasks([...]).
This tool is designed for CI pipelines, monorepos, and multi-step local dev workflows β not just simple "run two scripts at once."
---
- π¦ Installation
- π οΈ CLI Usage
- βοΈ npm-run-all-next
- βΆοΈ run-s (sequential)
- π run-p (parallel)
- π‘οΈ Common Options
- π Patterns & Placeholders
- π¦ Node API
- π€ Contributing
- π License
---
Install as a development dependency:
``sh`
npm install --save-dev npm-run-all-next
All commands are exposed in node_modules/.bin:
- βοΈ npm-run-all-nextrun-s
- βοΈ run-p
- βοΈ
You can also add them to your package.json scripts:
`jsonc`
{
"scripts": {
"build:js": "β¦",
"build:css": "β¦",
"lint": "β¦",
"clean": "β¦",
"test": "β¦",
"serial": "run-s clean lint build:*",
"parallel": "run-p lint test clean"
}
}
---
Mix sequential and parallel groups in one command:
`sh`
npm-run-all clean lint \
--parallel build:* \
--sequential test:* \
--parallel deploy
This runs:
1. clean then lint (serial)
2. build:\* tasks (parallel)
3. test:\* tasks (serial)
4. deploy (parallel with a single task)
---
Shortcut for npm-run-all --sequential:
`sh`
run-s clean lint build:js build:css
Equivalent to:
`sh`
npm run clean && npm run lint && npm run build:js && npm run build:css
---
Shortcut for npm-run-all --parallel:
`sh`
run-p test watch serve
Equivalent to (Unix shells):
`sh`
npm run test & npm run watch & npm run serve
> Windows cmd.exe does not group & wellβuse run-p instead.
---
| Flag | Description |
| ------------------------- | -------------------------------------------------------------------------- |
| -a, --aggregate-output | ποΈ Buffer each taskβs output and print when all finish (requires parallel) |
| -b, --balancer | βοΈ Balance tasks based on historical runtimes |
| -c, --continue-on-error | π§ Donβt stop other tasks when one fails |
| -k, --kill-others-on-fail | π₯ Kill remaining tasks on first failure (requires parallel) |
| -r, --race | π Stop remaining tasks when one succeeds (requires parallel) |
| -j, --jobs | π’ Max concurrent tasks (default: unlimited; requires parallel) |
| -t, --print-summary-table | π Show a summary table of results at the end |
| -l, --print-label | π·οΈ Prefix each output line with the task label |
| -n, --print-name | π Print the task name before running |
| --retries | π Retry each failed task up to times |
| --npm-path | π Path to a custom npm executable |npm_config_loglevel
| --silent | π€« Suppress all output (sets to silent) |
| -h, --help | β Show help |
| -v, --version | π Show version |
| --tasks-file
Short flags can be combined (e.g. -crs β -c -r -s).
---
Use glob-like patterns on script names (separator :, globstar ** supported):
`sh`
run-p 'build:*' # matches build:js, build:css
run-s 'test:**' # matches test:unit, test:unit:api, etc.
Forward arguments to scripts:
`sh`
run-p "start -- --port {1}" -- 8080π expands to: npm run start -- --port 8080
Placeholders:
- {1}, {2}, β¦ β 1st, 2nd, β¦ argument{@}
- β all args as an array{*}
- β all args joined
---
Brace expansion
If your shell doesnβt support brace expansion, npm-run-all will expand patterns like:
`sh`
run-p build:{a,b,c} # β> run-p build:a build:b build:c
β¦so you can target multiple scripts in one pattern.
`js
const { runTasks } = require("npm-run-all-next")
runTasks(["clean", "lint", "build:*"], {
parallel: true,
retries: 2,
killOthersOnFail: true,
printSummaryTable: true,
})
.then((results) => {
// results: [{ name: 'clean', code: 0 }, β¦]
console.log("β
Done:", results)
})
.catch((err) => {
console.error("β Failed:", err.results)
})
`
Options mirror CLI flags:
`ts``
interface RunOptions {
parallel?: boolean
aggregateOutput?: boolean
balancer?: boolean
continueOnError?: boolean
killOthersOnFail?: boolean
race?: boolean
jobs?: number
retries?: number
printSummaryTable?: boolean
printLabel?: boolean
printName?: boolean
npmPath?: string
silent?: boolean
stdin?: Stream
stdout?: Stream
stderr?: Stream
taskList?: string[]
}
---
Contributions, issues, and feature requests are welcome!
See CONTRIBUTING.md for guidelines.
---
---
| index | [npm-run-all] | [run-s] | [run-p] | [Node API] |
| ----- | ------------- | ------- | ------- | ---------- |
[npm-run-all]: docs/npm-run-all.md
[run-s]: docs/run-s.md
[run-p]: docs/run-p.md
[node api]: docs/node-api.md
---
MIT Β© 2025 Alec Mestroni