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

839 views Asked by At

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 (i.e. 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.

1

There are 1 answers

0
Robert On

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