In my package.json
I have these two scripts:
"scripts": {
"start-watch": "nodemon run-babel index.js",
"wp-server": "webpack-dev-server",
}
I have to run these 2 scripts in parallel everytime I start developing in Node.js. The first thing I thought of was adding a third script like this:
"dev": "npm run start-watch && npm run wp-server"
… but that will wait for start-watch
to finish before running wp-server
.
How can I run these in parallel? Please keep in mind that I need to see the output
of these commands. Also, if your solution involves a build tool, I’d rather use gulp
instead of grunt
because I already use it in another project.
30 s
Use a package called concurrently.
npm i concurrently --save-dev
Then setup your npm run dev
task as so:
"dev": "concurrently --kill-others \"npm run start-watch\" \"npm run wp-server\""