无法 运行 在 Windows 10 上全局安装 npm 包

Cannot run globally installed npm packages on Windows 10

我已经在 Windows 10 台机器上安装了 typescriptnodemon(使用标准 npm install -g [package-name]),但是当我通过终端 运行 它们时,我得到了应用程序选择器 window opened where I need to choose which app I will use to open the file.

谁能指出我如何解决它?它可能与已安装的 Visual Studio 有关吗?非常感谢任何帮助。

谢谢!

好吧,我已经找到了几个解决方案。

观察到的问题

上面提到的包包含绑定到 Unix shell 的文件,并且没有 Windows 到 运行 的批处理脚本。例如:

解决方案

  1. 创建名为 tsc.cmd 的文件(如果 tscC:\Users\[username]\AppData\Roaming\npm\node_modules\typescript\bin 目录中)并在其中放入以下代码:

    @node "%~dpn0" %*

  2. 使用 Git Bash 对我来说开箱即用:)