How to set shell for npm run-scripts in Windows

后端 未结 7 2065
执笔经年
执笔经年 2020-11-28 02:46

I\'m running npm on Windows and would like to use & style parallel operations in run-scripts but running in parallel in cmd is kind of messy in my package.json file I\'

7条回答
  •  一整个雨季
    2020-11-28 03:03

    Use a specifically created node_module for this purpose. I suggest using npm-run-all, but others exists, such as parallelshell.

    Parallelshell example is below for drop-in-replacement for your question.

    "scripts": {
        "parallelexample1": "parallelshell \"echo 1\" \"echo 2\" \"echo 3\""
    },
    

    following command:

    npm run parallelexample1
    

    works both on windows and unix(Linux/MacOS).

    Interestingly npm-run-all does not support shell commands; therefore we need to put all shell commands to separate scripts like below.

    "scripts": {
       "parallelexample2": "npm-run-all echo*",
        "echo1": "echo 1",
        "echo2": "echo 2",
        "echo3": "echo 3"
    },
    

    Following command:

    npm run parallelexample2
    

    works both on windows and unix(Linux/MacOS).

提交回复
热议问题