如何在 Windows 中为 npm run-scripts 设置 shell [英] How to set shell for npm run-scripts in Windows

查看:85
本文介绍了如何在 Windows 中为 npm run-scripts 设置 shell的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Windows 上运行 npm 并且想使用 &运行脚本中的样式并行操作但是在cmd中并行运行有点乱在我的 package.json 文件中我想写 -

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'd like to write-

scripts: { "go": "cmd1 & cmd2"} 

但是 npm 执行 cmd.exe 下的脚本,它不知道 ; 我可以将其更改为scripts: { "go": "bats/bat1.bat") 其中 bat1.bat 是一个 cmd bat 文件,它使用 Windows 风格的调用或启动命令来并行运行命令.它有效但给了我一个仅适用于 Windows 的脚本.

but npm executes the script under cmd.exe which does not know about ; I could change this to scripts: { "go": "bats/bat1.bat") where bat1.bat is a cmd bat file that uses the windows style call or start commands to run commands in parallel. which works but gives me a script that only works on Windows.

如果我能让 npm 在 bash 克隆或 cygwin 下运行脚本,那会简单得多.

It would be a lot simpler if I could get npm to run the script under a bash clone or cygwin.

我试过了config: { "shell": "bash"}但仍然运行 cmd.exe

I tried config: { "shell": "bash"} but that still ran cmd.exe

有没有办法告诉 npm 使用特定的 shell(不是 cmd.exe)运行脚本?

Is there any way to tell npm to run-scripts using a specific shell (not 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 安装.

npm config delete script-shell

这篇关于如何在 Windows 中为 npm run-scripts 设置 shell的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆