Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Starting TypeScript program from Visual Studio Code: "Cannot launch program 'hw.ts' because corresponding JavaScript cannot be found."

I have hw.ts file with this content:

function greeter(x: string) {
    return "Hello" + x;
}

let u = "John";
document.body.innerHTML = greeter(u);

I select Start without debugging and VSCode says:

Cannot launch program 'hw.ts' because corresponding JavaScript cannot be found.

OK so I compile file from the commandline:

tsc hw.ts

Now I do have hw.js in the same folder.

So again I select Start without debugging and VSCode again says Cannot launch program 'hw.ts' because corresponding JavaScript cannot be found..

Is there any way to compile & run TypeScript program from VSCode? What am I missing?

(I do have node in my PATH, it should be visible to VSCode)

like image 347
LetMeSOThat4U Avatar asked Feb 15 '18 19:02

LetMeSOThat4U


1 Answers

It worked for me as soon as I changed

  "outFiles": [
    "./dist/**/*.js"
  ],

to

  "outFiles": [
    "${workspaceFolder}/dist/**/*.js"
  ],
like image 73
Linus Avatar answered Oct 21 '22 08:10

Linus