nodemon with ts and vs code attach debugging connection timeout with --inspect

Viewed 684

I try to debug my node application that I wrote in ts. I want to debug with the ts source map of course but somehow it does not work with --inspect (connection timeout) and without (no sourcemaps but connects).

My npm command:

"dev": "nodemon -r source-map-support/register --watch ./src -e ts --exec \"npm run start\"",
"dev-inspect": "nodemon --inspect -r source-map-support/register ./src/index.ts --watch ./src -e ts --exec \"npm run start\"",

My ts settings:

{
  "compilerOptions": {
    "types": [
      "node"
    ],
    "declaration": true,
    "target": "es2016",
    "module": "commonjs",
    "outDir": "./build",
    "rootDir": "./src",
    "sourceMap": true,
    "incremental": true,
    "tsBuildInfoFile": "./build/.tsbuildinfo"
  },
  "include": [
    "./src/**/*"
  ]
}

My vs code attach configuration:

"version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "attach",
            "name": "Attach by Process ID",
            "processId": "${command:PickProcess}",
            "protocol": "inspector", // removed when tried without --inspect
        },

What do I do wrong here?

1 Answers

you have to set Node parameters in your Debug Configuration.

like this:- --require ts-node/register and inside java-script file you have to set server.ts or index.ts

enter image description here

Related