VSCode Node.js Typescript Debugging

Debugging ts-node

First create your launch.json ( visual studio code doc )
To allow breakpoints to work, we need to enable source maps in our launch.json as shown below:
.vscode/launch.json
1
{
2
"version": "0.2.0",
3
"configurations": [
4
{
5
"name": "Example",
6
"type": "node",
7
"request": "launch",
8
"runtimeExecutable": "node",
9
"runtimeArgs": ["--nolazy", "-r", "ts-node/register/transpile-only"],
10
11
"args": ["${file}", "--sample-arg", "test"],
12
13
"cwd": "${workspaceRoot}",
14
"internalConsoleOptions": "openOnSessionStart",
15
"skipFiles": ["<node_internals>/**", "node_modules/**"]
16
}
17
]
18
}
19
Copied!
Then get back to your file, and start the debugger.
debugger statement should hit now
Last modified 7mo ago
Copy link