Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I run multiple npm scripts at the same time?

In my package.json, I defined two scripts. How do I run them at the same time?

"scripts": {
    "server": "webpack-dev-server",
    "webpack": "webpack -wd",
},
like image 652
bob Avatar asked Dec 24 '17 00:12

bob


2 Answers

Invoke scripts via npm run with & for parallel execution or with && for sequential execution:

npm run server & npm run webpack

Explanation:

Use &&  for sequential execution.
Use &  for parallel execution.
like image 163
Danilo Calzetta Avatar answered Sep 17 '22 17:09

Danilo Calzetta


"scripts": {
    "sw": "webpack-dev-server & webpack -wd"
},

then

npm run sw
like image 26
胡亚雄 Avatar answered Sep 20 '22 17:09

胡亚雄