简体   繁体   中英

Typescript build task in VSCode on Windows 10 with Windows Subsystem for Linux

My VSCode settings (workspace settings in my case) are setup to use bash as the default terminal:

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

I need this to be able to debug my app.

My tasks.json looks like that:

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

So when I try to build my project / run the build task (ie Ctrl + B ), I get the following error:

> Executing task: tsc -p "c:\\PATH_TO_MY_PROJECT\\tsconfig.json" <

error TS5058: The specified path does not exist: 'c:\\PATH_TO_MY_PROJECT\\tsconfig.json'.

The terminal process terminated with exit code: 1

If I disable bash in my settings an use the default Windows terminal, the build works fine.

I remember it working few VSCode updates ago, but it stopped working in the latest VSCode versions. Not sure how that's related.

I tried to fix this for a while, but finally gave up on the built-in Typescript task and instead just used a custom task:

{
    // 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"
            ]
        }
    ]
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM