gpt4 book ai didi

windows - 如何在 Windows 中为 npm run-scripts 设置 shell

转载 作者:可可西里 更新时间:2023-11-01 11:55:44 24 4
gpt4 key购买 nike

我在 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com