DEV Community

Ramu Narasinga
Ramu Narasinga

Posted on

concurrently usage in n8n codebase.

In this article, we review Concurrently. You will learn:

  1. What is Concurrently?

  2. Concurrently in n8n codebase.

What is Concurrently?

Run multiple commands concurrently. Like npm run watch-js & npm run watch-less but better.

The usual way to run multiple commands concurrently is npm run watch-js & npm run watch-css. That's fine but it's hard to keep on track of different outputs. Also if one process fails, others still keep running and you won't even notice the difference.

Features:

  • Cross platform (including Windows)

  • Output is easy to follow with prefixes

  • With --kill-others switch, all commands are killed if one dies

Learn more about concurrently.

Concurrently in n8n codebase.

I found concurrently in n8n codebase at packages/cli/package.json.

{
  "name": "n8n",
  "version": "2.36.0",
  "description": "n8n Workflow Automation Tool",
  "main": "dist/index",
  "types": "dist/index.d.ts",
  "scripts": {
  ...
  "dev": "concurrently -k -n \"TypeScript,Node\" -c \"yellow.bold,cyan.bold\" \"pnpm run watch\" \"nodemon --delay 1\"",
  }
}
Enter fullscreen mode Exit fullscreen mode

Why concurrently? Like its explained above, concurrently provides outputs with prefixes when you have multiple scripts combined in a single script and is cross platform. I faced this issue in a project, on windows machine, where the dev script had & and as a result, it failed to run.

There are other scripts too where this concurrently is used in the same package.json file:

swift
...
"dev:worker": "concurrently -k -n \"TypeScript,Node\" -c \"yellow.bold,cyan.bold\" \"pnpm run watch\" \"nodemon worker\"",
"dev:webhook": "concurrently -k -n \"TypeScript,Node\" -c \"yellow.bold,cyan.bold\" \"pnpm run watch\" \"nodemon webhook\"",
...
Enter fullscreen mode Exit fullscreen mode

About me:

Hey, my name is Ramu Narasinga. Email: ramu.narasinga@gmail.com

I spent 3+ years studying OSS codebases and wrote 400+ articles on what makes the production-grade. Now I'm putting that into practice differently - instead of writing every fix myself, I run coding agents that do it.

How it works? Register your machine as a Runtime, point it at your repo. Agents pick up issues. write the fix, open the PR. You just review, they execute.

Build your coding agents and get more work done in less time at thinkthroo.com

References:

  1. npmjs.com/package/concurrently.

  2. github.com/n8n-io/n8n/packages/cli/package.json#L15.

Top comments (0)