- Initialize/Debug the applications in this order
- js-debug
- ts-debug
- express-debug
- nest-debug
-
Go to Debugger using
Ctrl + Shift + D
orโ + Shift + D
-
Create launch.json file
It will reside in the workspace directory under
.vscode
folder with namelaunch.json
-
Put the launch configuration inside the
launch.json
file and in thedebugger
select the configuration -
click on the green play button to attach the debugger
- it contains the local, global and closure variable present in the execution context
- Watch Window allows you to see value of variables and expressions while debugging.
- Shows the function call stack from named to anonymous function
- Shows the files that are currently in execution
- Shows all the breakpoints that you've given in all the files in the workspace
- Debugging JS Application
{
"type": "pwa-node",
"request": "launch",
"name": "JS-Launch",
"skipFiles": ["<node_internals>/**"],
"program": "${workspaceFolder}/js-debug/index.js",
"outFiles": ["${workspaceFolder}/**/*.js"]
},
- Debugging TS Application
{
"type": "pwa-node",
"request": "launch",
"name": "TS-Launch",
"skipFiles": ["<node_internals>/**"],
"program": "${workspaceFolder}/ts-debug/index.ts",
"preLaunchTask": "tsc: build - ts-debug/tsconfig.json",
"outFiles": ["${workspaceFolder}/ts-debug/**/*.js"],
"cwd": "${workspaceFolder}/ts-debug"
},
you need to have tsc compiler installed: `npm i -g typescript`
-
Debugging Express Application
debugging this process will require starting of the application and attaching the debugger to a processId
{
"name": "Express",
"processId": "${command:PickProcess}",
"request": "attach",
"skipFiles": ["<node_internals>/**"],
"type": "node"
},
- Debugging Express-Nodemon Application
{
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"name": "Nodemon-Express",
"program": "${workspaceFolder}/express-debug/app.js",
"request": "launch",
"restart": true,
"runtimeExecutable": "nodemon",
"skipFiles": ["<node_internals>/**"],
"type": "node"
},
- Debugging NESTJS Application using npm/yarn
{
"command": "cd nest-debug && yarn run start:dev",
"name": "NEST-Debug",
"request": "launch",
"type": "node-terminal"
},
- Debugging NESTJS Application using launch
{
"type": "pwa-node",
"request": "launch",
"name": "Debug-NEST",
"skipFiles": ["<node_internals>/**", "node_modules/**"],
"program": "${workspaceFolder}/nest-debug/src/main.ts",
"runtimeArgs": ["--no-lazy", "-r", "ts-node/register", "-r", "tsconfig-paths/register"],
"console": "integratedTerminal",
"sourceMaps": true,
"cwd": "${workspaceFolder}/nest-debug",
"internalConsoleOptions": "openOnSessionStart"
},