Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS Code Unverified Breakpoints

I'm trying to debug a Node/Express TypeScript app in VS Code (v. 1.24.0) and all my breakpoints are greyed out during debugging.

The error is "Unverified Breakpoint, Breakpoints set but not yet bound." I've searched but can't figure out what's wrong with my config. There is no error in the console, the debugger attaches successfully when I choose the process, but the breakpoints don't work.

How do I debug this?

basic folder structure:

/.vscode
/src/server.ts
/dist/server.js
launch.json
tsconfig.json

launch.json

{
            "type": "node",
            "request": "attach",
            "name": "Attach by Process ID",
            "processId": "${command:PickProcess}",
            "protocol": "inspector",
            "address": "localhost",
            "port": 8080,
            "restart": true,
            "preLaunchTask": "npm: build",
            "sourceMaps": true,
            "outFiles" : [ "${workspaceFolder}/dist/**/*.js" ]
        },

tsconfig.json

{
  "compilerOptions": {
    "alwaysStrict": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "module": "commonjs",
    "moduleResolution": "node",
    "target": "es6",
    "outDir": "dist",
    "rootDir": "src",
    "sourceMap": true,
    "typeRoots": [ "node_modules/@types" ]
  },
  "include": [
    "src/**/*.ts"
  ],
  "exclude": [
    "node_modules"
  ]
}

tasks.json

"version": "2.0.0",
    "tasks": [
        {
            "type": "npm",
            "script": "build",
            "group": {
                "kind": "build",
                "isDefault": true
            }
        } ]
like image 968
beachCode Avatar asked Jun 11 '18 18:06

beachCode


1 Answers

For anyone who runs into this error, I was able to find a solution. The issue was the way I was launching the Node process, not the mapping of the source maps (which produces a different error).

To attach to the process, I launched it from the VS Code terminal like this:

node --inspect dist/server.js

launch.json:

{
            "type": "node",
            "request": "attach",
            "name": "Attach by Process ID",
            "processId": "${command:PickProcess}",
            "protocol": "inspector",
            "address": "localhost",
            "port": 8080,
            "restart": true,
            "preLaunchTask": "npm: build",
            "sourceMaps": true,
            "outFiles" : [ "${workspaceRoot}/dist/**/*.js" ]
        },
like image 69
beachCode Avatar answered Oct 20 '22 03:10

beachCode