concurrently
repository·main·Indexed 27 days ago
https://github.com/open-cli-tools/concurrentlyA tool for running multiple commands concurrently in a single terminal session with prefixed output and cross-platform support. Version 10.0.4 provides both a Command Line Interface (CLI) and a programmatic API to execute commands in parallel, featuring output control, success condition monitoring, process restarting, and IPC support.
What's inside concurrently
- Concurrently is a tool designed to run multiple commands simultaneously. It can be used via a Command Line Interface (CLI) or through its programmatic API. When using either interface, be aware that shell resolution rules apply to how commands are parsed and executed.
Use passthrough arguments with concurrently
mainWhen running commands viaconcurrently, additional flags passed to the CLI (e.g.,npm run build -- --flag) are often parsed byconcurrentlyitself instead of being passed to the underlying commands. To fix this, use the--passthrough-argumentsor-Pflag. This flag instructsconcurrentlyto take everything following a--delimiter and distribute it to the input commands using specific placeholders.Install concurrently
mainYou can install
concurrentlyeither globally for system-wide use or locally as a development dependency for a specific project. It is recommended to add it todevDependencies.# Global installation npm i -g concurrently yarn global add concurrently pnpm add -g concurrently bun add -g concurrently # Local installation (recommended for devDependencies) npm i -D concurrently yarn add -D concurrently pnpm add -D concurrently bun add -d concurrentlyInherit shell configuration from npm, pnpm, or yarn v1
mainWhen running
concurrentlythrough apackage.jsonscript usingnpm,pnpm, oryarn v1,concurrentlywill inherit and use thescript-shellconfiguration from the package manager. This allows you to set a global shell for your scripts via the package manager's config.npm config set script-shell /bin/bash npm dev # Runs the dev script on bash. Concurrently will also run commands using bash.Override the default shell in concurrently
mainBy default,
concurrentlyusescmd.exeon Windows and/bin/shon other platforms. If you need to use a different shell (for example, to use Unix-style syntax likeBROWSER=noneon Windows by using Git Bash), you can provide an explicit shell override. This override takes precedence over all other configurations.# Via CLI concurrently --shell "C:\Program Files\Git\bin\bash.exe" "echo Hello world | xargs -n 1 echo" # Via API concurrently(['echo Hello world | xargs -n 1 echo'], { shell: 'C:\\Program Files\\Git\\bin\\bash.exe', });Terminate all commands only when a command fails
mainUse the
--kill-others-on-failflag to terminate all other running commands only if one of them exits with a non-zero exit code. This is useful in build pipelines where you want to abort all processes if any single build step fails.$ concurrently --kill-others-on-fail 'npm run app1:build' 'npm run app2:build'Enable input handling in concurrently
mainBy default,
concurrentlydoes not pass input (like keystrokes) to the spawned commands. To enable input handling, you must use the--handle-inputor-iflag. When enabled, input is sent to the first command by default.$ concurrently --handle-input 'nodemon' 'npm run watch-js'Use concurrently via CLI
mainRun multiple commands concurrently by passing them as quoted strings. The command
concurrentlyalso has a shorthand aliasconc.Important for Windows users: Windows only supports double quotes. When using
concurrentlyinside apackage.jsonscript on Windows, you must escape the double quotes.Use Concurrently via CLI
mainConcurrently provides a CLI for running multiple commands in parallel. The CLI supports various features including command prefixing, output control, success condition monitoring, command restarting, and custom configuration. For advanced usage, you can pass arguments through to the underlying commands.Terminate all commands when any command exits
mainUse the
--kill-othersflag to ensure thatconcurrentlyterminates all other running commands as soon as the first command exits, regardless of whether it succeeded or failed (exit code 0 or non-zero). This is useful for stopping a long-running server process once a test suite completes.$ concurrently --kill-others --names server,test 'npm start' 'npm test'Use package manager shortcuts in concurrently
mainYou can use shorthand syntax to execute scripts from
package.jsonordeno.(json|jsonc)files. When using these shortcuts,concurrentlyautomatically assigns the command name based on the script name.Supported shortcuts:
npm:<script>expands tonpm run <script>pnpm:<script>expands topnpm run <script>yarn:<script>expands toyarn run <script>bun:<script>expands tobun run <script>node:<script>expands tonode --run <script>(Requires Node 22+)deno:<script>expands todeno task <script>
$ concurrently 'pnpm:lint:js' # Is equivalent to $ concurrently -n lint:js 'pnpm run lint:js'Scope colors to specific parts of a prefix template
mainWhen using a custom
--prefixtemplate, you can restrict coloring to specific segments using{color}and{/color}markers. Any text outside these markers will use the terminal's default color.{color}: Starts the colored region.{/color}: Ends the colored region.
If a marker is left unclosed, the color will extend to the end (for
{color}) or from the start (for{/color}) of the prefix.