DEV Community

Cover image for How to run multiple npm scripts in parallel

How to run multiple npm scripts in parallel

Dan Vega on April 22, 2019

I was working on an exercise for our students and In the process, I learned something new. When our students finish their exercises they are asked ...
Collapse
 
irreverentmike profile image
Mike Bifulco

Whoa. That is a heck of a trick. It sounds like it might be supported on the Bash subsystem on Windows, rather than cmd.exe, which might be a reasonable workaround for folks using Windows.

Good work!

Collapse
 
weirdmayo profile image
Daniel Mayovsky

I just use tmux if I ever have to run more than one command of the same program in the same terminal. I also have tmux automation scripts, basically saving me a great deal of time. Instead of running
npm gulp, npm server at the same time, everytime I sit down to work on the project. I create a small TMUX script that will run those commands for me, and also start an editor and a browser with the project, and I just have to get to coding immediately.

Collapse
 
therealdanvega profile image
Dan Vega

I needed this to run on Windows as well so thats why I ended up with npm-run-all. Thanks for sharing information about tmux though!

Collapse
 
jrc86 profile image
Jonas • Edited

This made me curious.
You can use ^& for cmd, that will not throw errors.
"test":"npm run test:bla ^& npm run test:ble"
Currently running some tests, seems npm-run-all -p works better than ^&.

Collapse
 
therealdanvega profile image
Dan Vega

I will have to give that a shot, thank you Jonas!

Collapse
 
paulmicheli profile image
Paul Micheli

The problem have found with this, it leaves the http-server process running in the back ground, so you have to force quit the command with a 'ctrl+c'