VS代码未验证的断点 [英] VS Code Unverified Breakpoints

查看:235
本文介绍了VS代码未验证的断点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在VS Code(v。1.24.0)中调试Node / Express TypeScript应用,并且在调试期间所有断点均显示为灰色。

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.

我该如何调试?

基本文件夹结构:

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

launch.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

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

tasks.json

"version": "2.0.0",
    "tasks": [
        {
            "type": "npm",
            "script": "build",
            "group": {
                "kind": "build",
                "isDefault": true
            }
        } ]


推荐答案

对于遇到此错误的任何人,我都能找到解决方案。问题是我启动Node进程的方式,而不是源映射的映射(这会产生不同的错误)。

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).

要附加到进程,我启动了可以从VS Code终端中输入:

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

node --inspect dist/server.js

launch.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" : [ "${workspaceRoot}/dist/**/*.js" ]
        },

这篇关于VS代码未验证的断点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆