如何使用 WinPTY 运行 npm 脚本?

How to run npm scripts with WinPTY?

我遇到了 python freezing in Git bash on windows. Many answers on Whosebug suggested to use WinPTY 的已知问题。

当我使用时效果很好:

winpty python foo.py

但我 运行 一个 python 程序作为 npm 脚本的一部分。我的 package.json 有这个:

"scripts": {
  "start": "python foo.py && something else"
} 

所以我想我也需要 运行 带有 WinPTY 的 npm 脚本:

winpty npm start

但这不起作用。我在不同的环境中收到不同的错误消息。

  1. 我在工作时得到了 "Not found in PATH",它安装了最新的 git 和 npm,但是 它是 在路径中:

winpty: error: cannot start 'npm': Not found in PATH

  1. 我在我的个人电脑上遇到了一个不同的错误 git:

Error 0x2 starting npm start

知道为什么 npm 和 winpty 不能一起工作吗?

如果我 运行 npm start 没有 winpty 它工作正常。 winpty node 也有效。

我遇到了同样的问题。 实际上,在nodejs安装文件夹中,有npm.cmd 因此,使用 winpty 启动 npm 应该做的是

winpty npm.cmd install