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

标签 windows shell npm

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

相关文章:

shell - 如何像开发者命令提示符一样配置VS Code shell?

shell - telegraf 和脚本命令发送到 grafana

javascript - 使用 Node 获取的动态请求

reactjs - 浏览器列表 : caniuse-lite is outdated. 请运行下一个命令 `yarn upgrade`

windows - Delphi XE2 64 位应用程序和应用程序验证程序失败

c - c中计算机计算能力的上界

linux - Bash shell 脚本更新并打印覆盖同一行的变量

windows - 什么时候将 "..."添加到按钮的末尾?

c# - 适用于 Windows 的 NFC C# 库

node.js - 检查已安装的 angular-cli 版本?