Configs2026年5月29日·1 分钟阅读

Concurrently — Run Multiple Commands in Parallel from One Terminal

A CLI utility that runs multiple commands concurrently with prefixed, color-coded output in a single terminal window. Commonly used in package.json scripts to start a dev server and a file watcher side by side.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
Concurrently Overview
直接安装命令
npx -y tokrepo@latest install 540bfd80-5b7b-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run 确认安装计划,再运行此命令。

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 concurrently or run ad-hoc with npx
  • Use -n to assign custom names and -c to assign specific colors to each command
  • Set --kill-others to terminate all commands if any one exits
  • Set --kill-others-on-fail to only kill siblings when a command exits with a non-zero code
  • Use --prefix-colors with 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 repeating npm 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.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产