How can I run multiple npm scripts in parallel?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
Running multiple npm scripts in parallel is a common need during development. Typical examples include starting a backend server while a frontend watcher rebuilds assets, or running separate build pipelines for CSS and JavaScript at the same time.
Plain npm does not provide a rich built-in “run these scripts in parallel and manage their output” feature. In practice, developers usually choose either a shell-level background operator for simple local use or a helper package such as concurrently or npm-run-all for cross-platform projects.
The Simplest Approach: Shell Operators
On Unix-like shells, you can chain commands with &:
This works, but it has drawbacks:
- it is shell-dependent
- it behaves differently on Windows environments
- output from both commands can become messy
- process shutdown is not coordinated well
For one-person local scripts, it may be enough. For shared tooling, it is usually not the best choice.
Using concurrently
concurrently is a popular option because it is cross-platform and gives you readable prefixed output.
Install it as a development dependency:
Then define a combined script:
Now run:
This starts both scripts together and makes the output easier to follow.
A useful feature is coordinated shutdown. If one process fails, you can tell concurrently to terminate the others too.
Using npm-run-all
Another widely used option is npm-run-all, which supports both sequential and parallel orchestration.
Install it:
Then use its parallel mode:
This is concise and especially nice when you want to reference several named npm scripts instead of repeating full commands.
Choosing Between Them
A practical rule is:
- use shell
&only for quick local experiments - use
concurrentlywhen readable output and process control matter - use
npm-run-allwhen you want to orchestrate many named scripts in sequence and parallel combinations
Neither package changes what your scripts do. They only make process orchestration cleaner and more portable.
A Realistic Example
Suppose you have a frontend and backend in one project.
One npm run dev command now starts the whole local environment.
That is often the difference between a toolchain people actually use and one they avoid because it needs three separate terminals.
Common Pitfalls
A common mistake is assuming npm run a & npm run b is portable everywhere. It depends on the shell, so it is not a safe default for team projects.
Another mistake is ignoring process shutdown behavior. If one watcher fails and the other keeps running, developers may think the system is healthy when it is not.
People also forget to quote commands properly when using concurrently, especially in package.json where quoting rules matter.
Finally, do not solve every workflow problem with more parallelism. Some scripts depend on outputs from others and should run sequentially instead.
Summary
- npm scripts can be run in parallel, but plain npm offers limited orchestration by itself.
- Shell
&works for simple local cases but is not reliably cross-platform. - '
concurrentlyis a strong choice when you want readable logs and coordinated shutdown.' - '
npm-run-all --parallelis useful when orchestrating named npm scripts.' - Pick the tool based on portability, output clarity, and whether your tasks are truly independent.

