无法 运行 打字稿构建任务:'C:\Program' 未被识别为内部或外部命令

Unable to run typescript build task: 'C:\Program' is not recognized as an internal or external command

我正在尝试按照 documentation 将打字稿代码编译为 JavaScript。

我创建了 watch 任务来在按下 Ctrl+Shift+B 时编译 .ts 文件。但是,我在 运行 任务后收到错误消息:

'C:\Program' is not recognized as an internal or external command

我明白错误的原因,因为目录 Program Files 中有空格,我需要在它周围加上引号。

如何将构建命令更新为 运行 具有正确路径的编译器?

我必须更新 VS Code 的集成 shell 设置。

  1. 转到文件 > 首选项 > 设置
  2. 搜索 shell
  3. Select 适合您的操作系统的正确 shell 设置。
  4. 要么注释掉 "terminal.integrated.shellArgs.windows" 属性,要么更新它以转义目录周围的双引号。在我的例子中,是 Program Files 目录引起了麻烦。