Debugging
-
Inside the terminal panel of VSC, click on the dropdown menu and select
Create JavaScript Debug Terminal
.This will create a new terminal instance. To go back to the first terminal, you can select it from the same dropdown menu.
-
In this new debugging terminal, run the command that to run your code (ex.
tsx app.ts
,npm test
, depending on what you’re working on) and you should seeDebugger attached.
in the terminal, followed by the execution of the program, followed byWaiting for the debugger to disconnect...
. -
Set a breakpoint in
app.ts
by clicking to the left of any line number. -
Run your code again and the program should pause its execution on the line which you set the breakpoint.
-
Click on the debugger tab on the left navigation and you should see a list of all the current variables and their values.
- The variables and their values;
- The yellow bar indicating the program has paused execution;
- The output in the terminal;