Vscode-js-debug: Property `program` of launch config handles TypeScript files differently than current node debugger

Created on 25 Mar 2020  路  2Comments  路  Source: microsoft/vscode-js-debug

Issue Type: Bug

The current node debugger vscode-node-debug2 supports specifying a TypeScript file in the property program of launch configs, even when node is used to launch the program (instead of ts-node). In that case, it will not launch the file specified in program, but instead it will use the property outFiles to figure out where the program's transpile result is placed and run that.

To reproduce this, follow the steps outlined in the repository robin-hartmann/bug-vscode-node-debug2-breakpoints, which contains a minimal working example. That repository is actually meant for a different issue, but it mostly fits. Simply follow the instructions in the section Getting Started and then the ones in the section Workaround - just don't set any breakpoints and don't launch the program yet. Then in the launch.json for the configuration Launch with node set program to ${workspaceFolder}/src/bin.ts. Finally, build the project using npm build and launch it with the configuration Launch with node. It will fail with the following error:

C:\dev\private\bug-vscode-js-debugger-breakpoints\src\bin.ts:2
import { greet } from "./lib";
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at wrapSafe (internal/modules/cjs/loader.js:1072:16)
    at Module._compile (internal/modules/cjs/loader.js:1122:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
    at Module.load (internal/modules/cjs/loader.js:1002:32)
    at Function.Module._load (internal/modules/cjs/loader.js:901:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
    at internal/main/run_main_module.js:18:47
Process exited with code 1

That's because the vscode-js-debug debugger runs src/bin.ts instead of running dist/bin.js, which the current debugger vscode-node-debug2 does.

VS Code version: Code 1.43.2 (0ba0ca52957102ca3527cf479571617f0de6ed50, 2020-03-24T07:38:38.248Z)
OS version: Windows_NT x64 10.0.18363


System Info

|Item|Value|
|---|---|
|CPUs|Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz (8 x 3500)|
|GPU Status|2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
viz_display_compositor: enabled_on
viz_hit_test_surface_layer: disabled_off_ok
webgl: enabled
webgl2: enabled|
|Load (avg)|undefined|
|Memory (System)|31.93GB (25.87GB free)|
|Process Argv||
|Screen Reader|no|
|VM|0%|

Extensions (1)

Extension|Author (truncated)|Version
---|---|---
js-debug-nightly|ms-|2020.3.1617


bug verified

All 2 comments

Thanks for the issue and repro steps! There were two problems:

  • In node2--there was a change made to redirect the launch to js-debug _after_ config variables were substituted, but part of this redirection involved setting passing the ${workspaceFolder} in an internal parameter. Because that was after substitution, though, this meant js-debug was looking for sourcemaps in a folder literally called ./${workspaceFolder}.
  • We didn't normalize backslashes on windows which caused files to not match up, even when that was fixed

Thank you very much for the quick fix!
I can confirm it works now. 馃榿

Was this page helpful?
0 / 5 - 0 ratings

Related issues

roblourens picture roblourens  路  5Comments

michaelhyman picture michaelhyman  路  5Comments

isidorn picture isidorn  路  6Comments

jtsom picture jtsom  路  8Comments

FicoPrieto picture FicoPrieto  路  4Comments