How to set shell for npm run-scripts in Windows

后端 未结 7 2035
执笔经年
执笔经年 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:06

    Ideally, overriding the npm shell config parameter should work, but npm (at least version 1.4.14) seems in Windows to ignore the setting and use cmd.exe instead.

    Use the following command in your bash or Git Bash shell to find out the shell setting:

    $ npm config ls -l | grep shell
    

    By default, the output will be:

    shell = "C:\\WINDOWS\\system32\\cmd.exe"
    

    However, to override the default shell parameter, you can add (or edit) an npmrc file to the \Users\yourusername\AppData\Roaming\npm\etc directory. Just add the following line:

    shell = "C:\\Program Files (x86)\\git\\bin\\bash.exe"
    

    The path you use can be any valid path to bash.exe. Now, if you run the above "npm config ls -l | grep shell" command, you will see the following output, indicating that the shell parameter has been overriden:

    shell = "C:\\Program Files (x86)\\git\\bin\\bash.exe"
    ; shell = "C:\\WINDOWS\\system32\\cmd.exe" (overridden)
    

    One day, perhaps, a new version of npm will pay attention to the overridden shell parameter.

    0 讨论(0)
提交回复
热议问题