Using concurrently for cross-platform development in n8n
Описание и применение
Статья рассматривает использование пакета concurrently в кодовой базе n8n. Он решает проблемы с отслеживанием вывода и кроссплатформенной совместимостью при запуске нескольких команд одновременно, обеспечивая четкое форматирование вывода и корректную обработку ошибок.
Задача
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
concurrentlypackage via npm. - Update package.json scripts to use
concurrentlyinstead of shell operators. - Configure prefixes using the
-nflag (e.g.,-n "TypeScript,Node"). - Configure colors using the
-cflag (e.g.,-c "yellow.bold,cyan.bold"). - Add the
-kflag to kill other processes if one dies. - List the commands to run concurrently (e.g.,
pnpm run watchandnodemon).
Доказательства
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