VS Code 未经验证的断点

2024-01-10

我正在尝试在 VS Code (v. 1.24.0) 中调试 Node/Express TypeScript 应用程序,但在调试过程中我的所有断点都显示为灰色。

错误是“未验证断点,已设置断点但尚未绑定。”我已经搜索过,但无法弄清楚我的配置有什么问题。控制台中没有错误,当我选择进程时调试器成功附加,但断点不起作用。

我该如何调试这个?

基本文件夹结构:

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

启动.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"
  ]
}

任务.json

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

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

为了附加到该进程,我从 VS Code 终端启动它,如下所示:

node --inspect dist/server.js

启动.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" ]
        },
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

VS Code 未经验证的断点 的相关文章

随机推荐