Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vscode can't launch node app

I'm trying to set up a typescript-based express app workflow using Visual Studio Code & gulp.

Heres my project structure:

src/  <-- souce files
  Start.ts
  Server.ts
  models/
    Contact.ts
    Organization.ts
bin/  <-- compiled output
  Start.js 
  Start.js.map
  ...
tsconfig.json
gulpfile.json
package.json
.vscode/
  launch.json

Performing the following sequence of commands, I can compile & launch my app in the integrated terminal:

> tsc
> node --debug-brk ./bin/Start.js

At this point, I can successfully attach to my app using the default "attach to process" command (and it even hits breakpoints in the typescript files correctly, yeyy!):

{
    "type": "node",
    "request": "attach",
    "name": "Attach to Process",
    "address": "localhost",
    "port": 5858
}

However, launching with F5 fails every time. There is no output on the Debug Console, and in a few seconds I get an error banner at the top saying Cannot connect to runtime via 'legacy' protocol; consider using 'inspector' protocol (timeout after 10000 ms).

Here's my launch configuration (in launch.json):

{
    "type": "node",
    "request": "launch",
    "name": "Launch Program",

    // Using compiled .js file. vscode should use the sourcemap to correlate
    // with breakpoints in the source file
    "program": "${workspaceRoot}/bin/Start.js",
    "outFiles": [ "${workspaceRoot}/bin/**/*.js" ]
}

I tried opening the debug console. Every time I save the launch.json file, it gives me the following error: Cannot read property '_runner' of undefined: TypeError: Cannot read property '_runner' of undefined in shell.ts:426

Googling the error, I came across this bug

What does this bug mean? Is there any workaround for it? What oh what should I do???

like image 226
Julien Avatar asked Jul 04 '26 00:07

Julien


1 Answers

Small things always cause the biggest problems.

The issue was that I had the "Attach to Process" task selected (in the debug mode dropdown) rather then the "Launch Program" task. So, when I pressed F5, vscode was trying to attach to an already running process rather than launch a new one.

**facepalm**

like image 112
Julien Avatar answered Jul 05 '26 15:07

Julien



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!