Introduction
Concurrently is a Node.js CLI tool that runs multiple commands simultaneously in a single terminal session. It color-codes and prefixes each command's output so you can distinguish between processes at a glance. It is widely used in package.json scripts to start frontend and backend servers, file watchers, and build processes together.
What Concurrently Does
- Launches multiple shell commands in parallel from a single invocation
- Prefixes each command's stdout and stderr with a customizable name and color
- Supports npm script shorthand (
npm:dev,npm:build) to run package.json scripts by name - Kills all running processes when one exits, or keeps the rest alive based on configuration
- Returns a combined exit code based on configurable success/failure conditions
Architecture Overview
Concurrently spawns child processes using Node.js's child_process.spawn for each command. Each process's stdout and stderr streams are piped through a transform that prepends a colored prefix. A controller monitors process lifecycle events and applies the configured kill/restart policy. The tool supports running commands from package.json by resolving script names via npm's internal script runner.
Self-Hosting & Configuration
- Install as a dev dependency with
npm install -D concurrentlyor run ad-hoc withnpx - Use
-nto assign custom names and-cto assign specific colors to each command - Set
--kill-othersto terminate all commands if any one exits - Set
--kill-others-on-failto only kill siblings when a command exits with a non-zero code - Use
--prefix-colorswith ANSI color names or hex codes for custom styling
Key Features
- Color-coded, prefixed output makes it easy to identify which process produced each log line
- npm script shorthand (
npm:*wildcards) runs matching package.json scripts without repeatingnpm run - Configurable kill and restart policies for managing dependent processes
- Works on Linux, macOS, and Windows including Git Bash and PowerShell
- Lightweight with no native dependencies
Comparison with Similar Tools
- npm-run-all — runs npm scripts sequentially or in parallel; concurrently offers richer output formatting and process control
- GNU Parallel — powerful parallel command executor for shell; heavier and not designed for npm script workflows
- Mprocs — TUI-based process manager with split panes; concurrently uses a single merged output stream
- Foreman / Overmind — Procfile-based process managers; concurrently is simpler and works inline in npm scripts
FAQ
Q: Can I restart a command if it crashes?
A: Yes, use the --restart-tries and --restart-after flags to configure automatic restart behavior for failing commands.
Q: How do I run all npm scripts matching a pattern?
A: Use the npm:* wildcard syntax, for example concurrently "npm:watch-*" runs all scripts whose names start with watch-.
Q: Does concurrently work on Windows? A: Yes, it supports Windows natively including cmd.exe, PowerShell, and Git Bash.
Q: How do I control the exit code?
A: Use --success to define which command's exit code determines the overall result: first, last, all, or a specific command index.