- npm
- node.js
- tooling
- development
Introduction
Tired of opening multiple terminal tabs to run your dev server, API, and file watcher all at once? Yeah, me too. That's where concurrently
comes in.
This tiny npm package lets you run multiple commands simultaneously from a single terminal. No more juggling between tabs or trying to remember which process is running where.
Basic Usage
Instead of this madness:
- Tab 1:
npm run dev
- Tab 2:
npm run api
- Tab 3:
npm run watch
Do this:
npx concurrently "npm run dev" "npm run api" "npm run watch"
Each command gets its own color in the output, so you can actually tell what's happening.
Real Example
Here's how I use it in my projects:
{
"scripts": {
"dev": "concurrently -n frontend,backend -c green,blue \"pnpm -F=frontend run dev\" \"pnpm -F=backend run dev\""
}
}
Now npm run dev
fires up everything I need for development.
Actually, this is the exact script I use to run the monorepo that powers this very blog. One command starts both the frontend and backend with nice green and blue colors so I can tell them apart.
Pro Tips
Give your processes names so you know what's what
concurrently --names "WEB,API,DB" "npm run dev" "npm run api" "npm run database"
Instead of seeing random colors, you'll see "WEB", "API", "DB" next to each output line.
Kill everything when one thing crashes
concurrently --kill-others "npm run dev" "npm run api"
If your API crashes, this will also kill your frontend. Saves you from running broken setups.
Stop everything if anything fails
concurrently --kill-others-on-fail --prefix "{name}" "npm run dev" "npm run api"
Similar to above, but only kills when something actually fails (not just exits normally).
Why I love it
One command to rule them all. Start your entire dev environment with npm start
instead of remembering multiple commands. The output is clean since each process has its own color, so no more guessing which log belongs to what. It's easy to share with your team since members don't need to know 5 different commands to get started. Plus it works everywhere - CI, local dev, wherever you need it.
When not to use it
If you're just running one thing, don't bother. It's overkill for simple scripts.
Also, if your processes need to start in a specific order, you might want npm-run-all
instead.
Conclusion
Concurrently is one of those tools that just makes life easier. Install it once, set up your scripts, and never think about terminal management again.
It's not revolutionary, but it's damn useful.
Affiliate Links
Using these referral links helps support my work. I only recommend products I use and trust. Thank you for your support!