npm-run-all2 CLI
raw JSON →`npm-run-all2` is a command-line interface (CLI) tool designed to efficiently manage and execute multiple npm scripts. It enables running scripts concurrently in parallel or in a specified sequence, offering fine-grained control over complex build or development workflows. As a maintenance fork of the popular `npm-run-all` package, its primary focus is on ongoing maintenance, modernizing the codebase, and ensuring compatibility with recent Node.js versions. As of its current stable version 8.0.4, it specifically requires Node.js 20 or greater. It maintains a consistent release cadence, frequently incorporating updates and addressing compatibility concerns. Its key differentiator is its commitment to supporting contemporary Node.js environments and acting as a well-maintained alternative to its predecessor, particularly for projects that require updated dependencies or strict Node.js versioning.
Common errors
error Error: Minimum Node.js version not met. (Current: v16.x.x, Required: >=v20.x.x) ↓
20.5.0 or higher (e.g., using nvm install 20 && nvm use 20). error `npm-run-all2: command not found` or `Error: Cannot find module 'npm-run-all2'` ↓
npm-run-all2 locally as a devDependency (npm install --save-dev npm-run-all2) and ensure it's called via npm run <script> (which uses node_modules/.bin), or install it globally (npm install -g npm-run-all2) if you intend to use it directly from the terminal. error TypeError: require is not a function (after upgrading past 8.0.x) ↓
import statements (e.g., import { runAll } from 'npm-run-all2';). error No such task: <script-name> (Did you mean <similar-script-name>?)` or unexpected script globbing results. ↓
package.json and adjust the glob pattern accordingly. For v8.0.2, consider upgrading to v8.0.3+ to revert to minimatch glob behavior. Warnings
breaking `npm-run-all2` has progressively raised its minimum Node.js version requirement. Version `8.0.0` requires Node.js `>=20.0.0`, while `7.0.0` required `^18.17.0 || >=20.5.0`. Ensure your Node.js environment meets these requirements to avoid execution failures. ↓
breaking Starting with `v8.1.0-beta.0`, the codebase has largely converted to ES Modules. Programmatic users currently using `require('npm-run-all2')` will need to switch to ESM `import` statements when `v8.1.0` (or later versions) is officially released. This impacts how the library is consumed programmatically. ↓
gotcha In `v8.0.2`, the internal glob matching library was switched from `minimatch` to `picomatch`, which was then reverted back to `minimatch` in `v8.0.3` due to unforeseen issues. Users on `v8.0.2` might have experienced different or incorrect glob matching behavior for script names compared to `v8.0.1` or `v8.0.3+`. ↓
gotcha This package is a maintenance fork of `npm-run-all`. While generally compatible, `npm-run-all2` aims for more modern Node.js support and active maintenance. Ensure you are explicitly using `npm-run-all2` if you intend to benefit from its updated dependencies, stricter Node.js versioning, or active bug fixes not present in the original. ↓
Install
npm install npm-run-all2 yarn add npm-run-all2 pnpm add npm-run-all2 Imports
- runAll wrong
const runAll = require('npm-run-all2')correctimport { runAll } from 'npm-run-all2' - runAllSync wrong
const runAllSync = require('npm-run-all2').runAllSynccorrectimport { runAllSync } from 'npm-run-all2' - CLI Entrypoint (programmatic) wrong
import { cli } from 'npm-run-all2'correctimport 'npm-run-all2/bin/npm-run-all2.js'
Quickstart
{
"name": "my-project",
"version": "1.0.0",
"scripts": {
"clean": "rm -rf dist",
"lint": "eslint .",
"build:css": "sass src/styles.scss dist/styles.css",
"build:js": "rollup -c",
"build": "npm-run-all2 build:*",
"dev:server": "node server.js",
"dev:watch:css": "sass --watch src/styles.scss:dist/styles.css",
"dev:watch:js": "rollup -cw",
"start": "npm-run-all2 --parallel dev:server 'dev:watch:*'",
"full-setup": "npm-run-all2 clean lint build --sequential start"
},
"devDependencies": {
"npm-run-all2": "^8.0.0",
"eslint": "^8.0.0",
"sass": "^1.0.0",
"rollup": "^4.0.0"
}
}
// To run the parallel development setup:
npm start
// To run the full setup sequentially:
npm run full-setup