Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS Code - Failed to launch external program tsc.exe

I keep getting the "Failed to launch external program tsc.exe" in VS Code. I have installed typescript and set my path to where tsc.exe is located. Any suggestions Here is my task file

// The command is tsc.
"command": "tsc",

// Show the output window only if unrecognized errors occur. 
"showOutput": "silent",

// Under windows use tsc.exe. This ensures we don't need a shell.
"windows": {
    "command": "tsc.exe"
},

// args is the HelloWorld program to compile.
"args": ["HelloWorld.ts"],

// use the standard tsc problem matcher to find compile problems
// in the output.
"problemMatcher": "$tsc"
like image 755
Kevin McGregor Avatar asked Apr 30 '15 16:04

Kevin McGregor


3 Answers

You should try to install tsc this way:

npm install -g typescript

And then change tasks.json to:

...
       "windows": {
            "command": "tsc.cmd"
        },
        "args"   : ["Myfilename.ts"]
...

And everything should work as expected, also, try to read this:

https://code.visualstudio.com/Docs/tasks

Well,

I came up with my own solution to generate modified version of tasks.json each time you config task runner(CTR), but I don't know if this is a really good pratice as VSCode is brand new I've not found a better solution, If anyone knows how to change CTR in the proper way PLEASE let me know!

There is a file called taskSampleConfig.json that is parsed everytime CTR runs, and this file is inside VSCode folder, so you may change it to:

...
           "windows": {
                "command": "tsc.cmd"
            },
...
like image 172
jrabello Avatar answered Oct 03 '22 18:10

jrabello


Since I can't comment yet I post it as an answer:

Since tsc.cmd must be executed in a command interpreter you need to configure it like this:

"windows": {
    "command": "tsc",
    "isShellCommand": true
}

The taskSampleConfig.json file is basically used as a template if VSCode can't auto detect a task runner. There is currently no support to customize the templating.

like image 23
Dirk Bäumer Avatar answered Oct 03 '22 19:10

Dirk Bäumer


For me it works that way (Using VSCode in Admin-Mode on Win8):

  1. Installing Typescript via npm (as jrabello wrote)
  2. Setting up the task like this:

    "version": "0.1.0",
    "command": "tsc",
    "showOutput": "silent",
    "isShellCommand": true 
    
  3. Creating a tsconfig.json for your project with the compiler-options you need:

    "compilerOptions": {
        "target": "ES5",
        "module": "commonjs",
        "sourceMap": true
    }
    
like image 31
Chris Avatar answered Oct 03 '22 19:10

Chris