运行构建任务/ TSC中的VSCode路径生成失败:构建

Mat*_*att 1 typescript visual-studio-code

我正在通过https://code.visualstudio.com/docs/languages/typescript上的Typescript简介进行工作

当我尝试Run Build Task选择时tsc: build,VSCode尝试以下操作:

Executing task: tsc -p c:\work\JavascriptTypescript\test-apr-2018\tsconfig.json <

error TS5058: The specified path does not exist: 'c:workJavascriptTypescripttest-apr-2018tsconfig.json'.
The terminal process terminated with exit code: 1
Run Code Online (Sandbox Code Playgroud)

它试图使用tsconfig.json文件的完整路径,然后从该路径中删除斜杠。显然,这将找不到正确的文件。

如果我tsc -p tsconfig.json从命令行手动发出,则tsc可以正常工作。

这似乎是VSCode配置错误,但我是VSCode的新手,也不知道如何解决它。

v-a*_*rew 10

将任务的 shell 更改为cmd.exe

    "terminal.integrated.automationProfile.windows": {
        "path": "C:\\Windows\\System32\\cmd.exe"
    }
Run Code Online (Sandbox Code Playgroud)

现在您可以保留bash作为终端的外壳,并且构建任务将使用以下命令执行cmd.exe

更改该值

  1. 打开设置编辑器CTRL+,或文件->首选项->设置
  2. 在搜索中输入Automation
  3. 选择Edit in settings.json 在此输入图像描述

仅供参考,
任务是否可以使用与为集成终端指定的 shell 不同的 shell?


Mat*_*att 8

当在Windows上使用Git Bash作为终端在VSCode上使用时,这是一个已知问题(截至2018-04-20)。参见https://github.com/Microsoft/vscode/issues/35593

为终端切换到CMD是一种解决方法。如上所述,手动调用tsc也是如此。


小智 6

此问题的另一个解决方案是创建一个运行 tsc 的 npm 脚本,然后在 VSCode launch.json 中运行该脚本。

包.json:

"scripts": { "debug": "tsc --sourcemap" },

.vscode/launch.json:

{ "type": "node", "request": "launch", "name": "Debugger", "program": "${workspaceFolder}/app.ts", "preLaunchTask": "npm: debug", "outFiles": [ "${workspaceFolder}/*.js" ] }