在 Windows 上,如何从新 windows 中的 运行 个进程中停止 npm?

On Windows, how can I stop npm from running processes in new windows?

当我在我的 Windows 10 机器上 运行 npm 命令时,新进程似乎在新 windows.

中产生

在我(Mac-使用)同事的机器上,我看到这些命令 运行 在调用它们的同一终端 window 中。这是我期望的行为并且更有用 - 例如,很难在它们完成和终端关闭之间的瞬间看到我的测试结果 window!

例如,我们的 packages.json 有一个脚本 运行 jest:

scripts": {
    "test": "jest"
}

当我 运行 npm run test 时,以下内容被写入当前终端:

$ npm run test

> @headuplabs/mobile@0.0.1 test C:\Users\TomWright\Documents\Repos\HeadUp.Mobile
> jest

但是 jest 的实际执行是在新创建的 window:

中开始的

我在 VS Code 中使用 "git bash" 作为我的默认集成终端,但我可以使用 cmd.exe 和 VS Code 外部(即通过 运行ning 复制它git bash 或 cmd 独立)。

我认为我的 npm 安装配置不正确,但我的 Google 搜索没有得到任何答案。

有谁知道我需要做什么才能在同一个终端 运行 中创建 npm 进程 window?

如“how to set shell for npm run-scripts in windows”中所述,您可能需要在 npm 本身中配置 shell:

npm config set script-shell "C:\Program Files\git\bin\bash.exe"

这将避免默认设置,默认设置会触发新的 shell window。