How can I run multiple npm scripts in parallel?

后端 未结 22 2495
灰色年华
灰色年华 2020-11-22 05:48

In my package.json I have these two scripts:

  \"scripts\": {
    \"start-watch\": \"nodemon run-babel index.js\",
    \"wp-server\": \"webpack-         


        
22条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-22 06:20

    ... but that will wait for start-watch to finish before running wp-server.

    For that to work, you will have to use start on your command. Others have already illustrated but this is how it will work, your code below:

    "dev": "npm run start-watch && npm run wp-server"

    Should be :

    "dev": " start npm run start-watch && start npm run wp-server"

    What this will do is, it will open a separate instance for each command and process them concurrently, which shouldn't be an issue as far as your initial issue is concerned. Why do I say so? It's because these instances both open automatically while you run only 1 statement, which is your initial goal.

提交回复
热议问题