Run npm commands recursively across multiple package.json directories with parallel execution support
npm install npm-recursive-runnerA powerful utility to recursively run npm commands in any child directory that has a package.json file. Formerly known as npm-recursive-install, this enhanced version allows you to run any command (not just npm install), with support for parallel execution.
- Run any npm command recursively across all package.json directories
- Skip node_modules and other specified directories
- Parallel execution with configurable concurrency
- Production mode support for install commands
- Customizable directory filtering
``bash`
npm install npm-recursive-runner --save-dev
- --command : Specify the command to run in each directory (default: npm install)--production
- : When using install commands, add the --production flag to skip dev dependencies--parallel
- : Run commands in parallel for faster execution--concurrency
- : Set the maximum number of concurrent processes (default: 4)--rootDir
- : Specify the root directory to start searching for package.json files--skipRoot
- : Skip execution for the root package.json--skip
- : Skip execution for specific directories--includeDirectories
- : Add specific directories for command execution
Run npm install in all package.json directories:
`bash`
$ npm-recursive-runner
Run npm ci instead of npm install:
`bash`
$ npm-recursive-runner --command="npm ci"
Run a build script in all packages:
`bash`
$ npm-recursive-runner --command="npm run build"
Clean node_modules directories:
`bash`
$ npm-recursive-runner --command="rm -rf node_modules"
Run installations in parallel (4 concurrent processes by default):
`bash`
$ npm-recursive-runner --parallel
Run with custom concurrency level:
`bash`
$ npm-recursive-runner --parallel --concurrency=8
Skip specific directories:
`bash`
$ npm-recursive-runner --skip dist build
Start from a specific directory:
`bash`
$ npm-recursive-runner --rootDir=packages
Skip root directory but process all others:
`bash`
$ npm-recursive-runner --skipRoot
Include specific directories:
`bash`
$ npm-recursive-runner --skip dist --includeDirectories dist/special-package
Install dependencies without dev dependencies:
`bash`
$ npm-recursive-runner --production
Run a clean script in parallel across all packages except test packages:
`bash``
$ npm-recursive-runner --command="npm run clean" --parallel --skip test-*
This package is an enhanced version of npm-recursive-install originally created by Matt Green, extended with support for custom commands and parallel execution.
MIT