【问题标题】:Typescript build task in VSCode on Windows 10 with Windows Subsystem for Linux带有适用于 Linux 的 Windows 子系统的 Windows 10 上的 VSCode 中的 Typescript 构建任务
【发布时间】:2023-03-06 11:43:01
【问题描述】:

我的 VSCode 设置(在我的例子中是工作区设置)设置为使用 bash 作为默认终端:

{
   "terminal.integrated.shell.windows": "C:\\WINDOWS\\Sysnative\\bash.exe"
}

我需要这个才能调试我的应用程序。

我的tasks.json 看起来像这样:

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "typescript",
            "tsconfig": "./tsconfig.json",
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

所以当我尝试构建我的项目/运行构建任务(即Ctrl + B)时,我收到以下错误:

> 执行任务:tsc -p "c:\PATH_TO_MY_PROJECT\tsconfig.json"

错误 TS5058:指定的路径不存在:'c:\PATH_TO_MY_PROJECT\tsconfig.json'。

终端进程以退出代码终止:1

如果我在设置中禁用 bash 并使用默认的 Windows 终端,则构建工作正常。

我记得它在几个 VSCode 更新前工作过,但它在最新的 VSCode 版本中停止工作。不知道这有什么关系。

【问题讨论】:

  • 这里相同 - 尽管在 bash shell 中路径不存在已删除所有斜杠:错误 TS5058:指定路径不存在:'c:PATHTOMYPROJECTtsconfig.json'。

标签: node.js typescript visual-studio-code windows-subsystem-for-linux vscode-tasks


【解决方案1】:

我尝试修复了一段时间,但最终放弃了内置的 Typescript 任务,而是使用了自定义任务:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Typescript watch",
            "type": "shell",
            "command": "tsc --watch",
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "presentation": {
                "reveal": "always",
                "panel": "new"
            },
            "problemMatcher": [
                "$tsc"
            ]
        }
    ]
}

【讨论】:

    猜你喜欢
    • 2017-12-14
    • 2017-02-26
    • 2021-12-31
    • 2016-07-27
    • 2018-06-09
    • 2019-06-07
    • 2019-07-03
    • 2019-01-09
    • 2019-02-24
    相关资源
    最近更新 更多