Im using npm scripts, I have some of them that should run in parallel. I've got something like this:
...
scripts: {
"a": "taskA &",
"preb": "npm run a",
"b": "taskB"
}
...
This is fine! But I'd like to kill automatically taskA running the background after taskB has finished.
How can I do that? Thanks!
To stop a running npm process, press CTRL + C or close the shell window.
Use the npm start to start a package. As of the [email protected], you can make use of custom arguments when executing scripts. This command is used to stop a package. This command will run the stop script that is provided by the package.
Nope, Anything you change over code, build will rerun for that change.
Using the concurrently package looks like a less tricky & painful way. This avoids detached processes (&
) alltogether. And promises to be more cross-plattform, too.
npm install concurrently --save
and then in package.json
"runBoth": "concurrently \"npm run taskA\" \"npm run taskB\"",
Tested (under Ubuntu 16.04, npm 5.6), also see here.
The npm-run-all
package may be what you're looking for:
$ npm install --save npm-run-all
Then in your package.json
file:
"scripts": {
"runA": "taskA",
"runB": "taskB",
"runBoth": "npm-run-all -p runA runB"
}
(-p
runs them in parallel, use -s
for sequential.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With