npm-run-all2 CLI

raw JSON →
8.0.4 verified Thu Apr 23 auth: no javascript

`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.

error Error: Minimum Node.js version not met. (Current: v16.x.x, Required: >=v20.x.x)
cause The installed Node.js version is older than the minimum required by `npm-run-all2`.
fix
Upgrade your Node.js environment to version 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'`
cause The `npm-run-all2` package is not installed or not accessible in the current execution path.
fix
Install 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)
cause Attempting to use CommonJS `require()` for programmatic imports after `npm-run-all2` has converted to ES Modules (from v8.1.0-beta.0 onwards).
fix
Refactor your code to use ESM 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.
cause The glob pattern used for script selection does not match any existing scripts, or the glob behavior is not what was expected.
fix
Verify the script names in package.json and adjust the glob pattern accordingly. For v8.0.2, consider upgrading to v8.0.3+ to revert to minimatch glob behavior.
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.
fix Upgrade your Node.js environment to version `20.5.0` or higher.
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.
fix Refactor programmatic imports from CommonJS `require()` to ESM `import { /* ... */ } from 'npm-run-all2'`.
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+`.
fix Upgrade to `8.0.3` or higher to ensure consistent `minimatch` glob behavior.
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.
fix Explicitly install `npm-run-all2` (e.g., `npm install --save-dev npm-run-all2`) and ensure your `package.json` scripts call `npm-run-all2` instead of `npm-run-all`.
npm install npm-run-all2
yarn add npm-run-all2
pnpm add npm-run-all2

Demonstrates `npm-run-all2` for parallel and sequential execution of npm scripts, including glob patterns, in a typical project setup.

{
  "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