Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Using concurrently for cross-platform development in n8n

说明与用途

本文回顾了 n8n 代码库中 concurrently 包的使用。它解决了同时运行多个命令时的输出跟踪和跨平台兼容性问题,提供了清晰的输出格式和适当的错误处理。

问题

Running multiple commands concurrently using shell operators like '&' is difficult to track due to mixed output and fails on Windows. Additionally, if one process fails, others continue running unnoticed.

结果

The n8n codebase uses concurrently to run TypeScript watching and Node.js processes simultaneously. This setup provides clear, prefixed output, ensures cross-platform compatibility, and handles process failures gracefully by killing dependent processes.

工作流

  • Install the concurrently package via npm.
  • Update package.json scripts to use concurrently instead of shell operators.
  • Configure prefixes using the -n flag (e.g., -n "TypeScript,Node").
  • Configure colors using the -c flag (e.g., -c "yellow.bold,cyan.bold").
  • Add the -k flag to kill other processes if one dies.
  • List the commands to run concurrently (e.g., pnpm run watch and nodemon).

证据

concurrently -k -n "TypeScript,Node" -c "yellow.bold,cyan.bold" "pnpm run watch" "nodemon --delay 1"

来源

I faced this issue in a project, on windows machine, where the dev script had & and as a result, it failed to run.

来源

  • 记录日期: 2026-09-05T13:44:33.630Z