Nestjs how to debug while editing code in VS code

Viewed 1802

I see there is a couple of answers making custom setups for debugging a NestJs application. However, I noted that in the standard package.json there is a script available "start:debug": "nest start --debug --watch",.

I tried to create a launch.json with the following setup.

{
    "type": "node",
    "request": "launch",
    "name": "Debug Program",
    "cwd": "${workspaceFolder}",
    "runtimeExecutable":"npm",
    "runtimeArgs":["run","start:debug"],
    "autoAttachChildProcesses":true
}

This works fine until i start editing the code. After that breakpoints are completely ignored, even if I remove and add them again.

1 Answers
  1. Open Vscode, and enter CTRL+SHIFT+P, select Toggle auto attach, choose always
  2. Click the code line you want to debug
  3. npm run start
Related