Closed swyxio closed 1 year ago
I think npm-run-all, which I just happen to have used, also supports labeled output. Doesn't support colors tho, iirc.
This does not actually need any extra packages at all, just a better package manager :smile:
Using the pnpm package manager, just use a regex to run multiple scripts concurrently, eg.
$ pnpm run /^build:/
Very helpful, tnx!
category: tutorial slug: parallel-npm-scripts description: Just a quick tutorial and explanation of how best to set up concurrently with named and colored log output since I had to look it up today.
There are two leaders in the parallel npm scripts game:
concurrently
andnpm-run-all
:https://npmcharts.com/compare/concurrently,npm-run-all?interval=30
Both have very similar features but we will just focus on
concurrently
as it is sliiiightly more flexible and nicely documented (this is not a strong opinion).Step 1 - Install the thing
Do I really need to explain?
Step 2 - Setup Concurrently
Assuming you have two scripts in package.json you want to run concurrently:
Now you can start them with
npm start
!But wait, this log output is a bit hard to read. Can we do better?
This is the beautiful third step.
Step 3 - Name and Color
Now you can tell at a glance where logs are coming from!