我在 Windows 上运行 npm 并希望在运行脚本中使用 & 风格的并行操作 但是在cmd中并行运行有点乱 在我的 package.json 文件中,我想写-
scripts: { "go": "cmd1 & cmd2"}
但 npm 在 cmd.exe 下执行脚本,它不知道 ;
我可以将其更改为
scripts: { "go": "bats/bat1.bat")
其中 bat1.bat 是一个 cmd bat 文件,它使用 windows 风格的调用或启动命令来并行运行命令。这有效,但给了我一个只适用于 Windows 的脚本。
如果我能让 npm 在 bash 克隆或 cygwin 下运行脚本,那就简单多了。
我试过了
配置:{“shell”:“bash”}
但它仍然运行 cmd.exe
有没有办法告诉 npm 使用特定的 shell(不是 cmd.exe)运行脚本?
最佳答案
从 npm 5.1 开始
npm config set script-shell "C:\\Program Files (x86)\\git\\bin\\bash.exe"
或(64位安装)
npm config set script-shell "C:\\Program Files\\git\\bin\\bash.exe"
请注意,您需要有 git for windows installed .
你可以通过运行恢复它:
npm config delete script-shell
关于windows - 如何在 Windows 中为 npm run-scripts 设置 shell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23243353/