7

I have tried many solutions but not anyone works for me. The code executes, but I am not able to place breakpoints & debug it. Could you please help me?

I have tried the following VSCode configuration script:

{
      "type": "node",
      "request": "launch",
      "name": "Typescript Node JS",
      "program": "${workspaceFolder}/build/server",
      "preLaunchTask": "npm: build",
      "sourceMaps": true,
      "stopOnEntry": false,
      "internalConsoleOptions": "openOnSessionStart",
      "outFiles": [
          "${workspaceFolder}/out/**/*.js"
      ]
    },
    {
      "name": "ts node",
      "type": "node",
      "request": "launch",
      "args": [
        "${workspaceFolder}/server"
      ],
      "runtimeArgs": ["--nolazy", "-r", "ts-node/register"],
      "sourceMaps": true,
      "cwd": "${workspaceRoot}",
      "protocol": "inspector"
    }
3
  • Did you solve your problem?..I am facing the same issues to catch breaking points.
    – Digs
    Commented Jul 27, 2020 at 7:49
  • yes.. I solved it. will post the solution. Commented Jul 27, 2020 at 8:19
  • @Digs Sorry for the delay. I have posted the solution now. Commented Sep 22, 2020 at 8:42

2 Answers 2

8
  1. Add the start script to package.json

    "scripts": { "start": "node ./node_modules/.bin/ts-node -- ./server.ts" }

  2. click on the debug menu icon on the left side navigation menu.

  3. Now click on show all automatic debug configurations.

  4. Now click on Node.Js(preview)

  5. Now all the scripts you have on package.json will be popped up. choose the start script.

  6. All Done!! Now breakpoints will work as expected :)

Note: Please make sure you have the latest version of VSC, in the older versions it will not work.

0

I checked all the solutions and none of them worked for my case. at last, I cleared the "outFiles" line and it worked!

just comment out these lines:

  "outFiles": [
      "${workspaceFolder}/out/**/*.js"
  ]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.