bea*_*ode 18 debugging node.js express typescript visual-studio-code
我正在尝试在VS Code(v。1.24.0)中调试Node / Express TypeScript应用程序,并且在调试期间所有断点均显示为灰色。
错误为“未验证的断点,设置了断点但尚未绑定。” 我已经搜索过,但无法弄清楚我的配置出了什么问题。控制台中没有错误,当我选择进程时,调试器将成功附加,但是断点不起作用。
我该如何调试?
基本文件夹结构:
/.vscode
/src/server.ts
/dist/server.js
launch.json
tsconfig.json
Run Code Online (Sandbox Code Playgroud)
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" ]
},
Run Code Online (Sandbox Code Playgroud)
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"
]
}
Run Code Online (Sandbox Code Playgroud)
task.json
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "build",
"group": {
"kind": "build",
"isDefault": true
}
} ]
Run Code Online (Sandbox Code Playgroud)
bea*_*ode 10
对于遇到此错误的任何人,我都能找到解决方案。问题是我启动Node进程的方式,而不是源映射的映射(这会产生不同的错误)。
为了附加该过程,我从VS Code终端启动了它,如下所示:
node --inspect dist/server.js
Run Code Online (Sandbox Code Playgroud)
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" ]
},
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
20517 次 |
最近记录: |