Executing Concurrent NPM Scripts
●
1 minute(s) to read
●
Permalink
●
suggest edit
All along, we’ve been able to run multiple NPM scripts in the same run command. Here’s the scenario: Imagine that we have a script that is called buildStaging and another called buildProduction. We could run both scripts out of the box with NPM by creating a new script, let’s call it build and setting the value to npm run buildStaging && npm run buildProduction. The problem with this is that buildProduction won’t start until buildStaging is complete.
At times, we’ll want to run NPM scripts concurrently. There are several ways you can run NPM scripts in parallel. We would need to bring in a package. Here are a few packages that would solve this along with a sample snippet to run the build script above concurrently:
- npm-run-all - Change the
buildscript to have a value ofnpm-run-all --parallel buildStaging buildProduction - concurrently - Change the
buildscript to have a value ofconcurrently --kill-others \"npm run buildStaging\" \"npm run buildProduction\" - parallelshell - Change the
buildscript to have a value ofparallelshell \"npm run buildStaging\" \"npm run buildProduction\"
Jason N. Gaylord

