gpt4 book ai didi

VS Code 中的 Angular 调试 - 断点未绑定(bind)

转载 作者:行者123 更新时间:2023-12-05 05:43:55 25 4
gpt4 key购买 nike

我正在尝试在 VS Code 中调试我的 Ionic/Angular 项目,但是一旦我启动 Debug模式,我所有的断点都会变成灰色并变得未绑定(bind)。

这是我的 launch.json:

{
"name": "Launch Chrome",
"request": "launch",
"type": "pwa-chrome",
"url": "http://localhost:8100",
"webRoot": "${workspaceFolder}"
}

我的 Angular 版本是 13.2.3,我的 Node 版本是 16.14.2。

我在 angular.json 文件中将 souceMap 设置为 true 并尝试调整设置,但没有任何效果。

感谢您的帮助!

最佳答案

VS code 团队提供了一套说明 here

基本上,您可以像这样配置/创建您的 launch.json:

{
"version": "0.2.0",
"configurations": [
{
"name": "ng serve",
"type": "chrome",
"request": "launch",
"preLaunchTask": "npm: start",
"url": "http://localhost:4200/#",
"webRoot": "${workspaceFolder}",
"sourceMapPathOverrides": {
"webpack:/*": "${webRoot}/*",
"/./*": "${webRoot}/*",
"/src/*": "${webRoot}/*",
"/*": "*",
"/./~/*": "${webRoot}/node_modules/*"
}
},
{
"name": "ng test",
"type": "chrome",
"request": "launch",
"url": "http://localhost:9876/debug.html",
"webRoot": "${workspaceFolder}",
"sourceMaps": true,
"sourceMapPathOverrides": {
"webpack:/*": "${webRoot}/*",
"/./*": "${webRoot}/*",
"/src/*": "${webRoot}/*",
"/*": "*",
"/./~/*": "${webRoot}/node_modules/*"
}
},
{
"name": "ng e2e",
"type": "node",
"request": "launch",
"program": "${workspaceFolder}/node_modules/protractor/bin/protractor",
"args": ["${workspaceFolder}/e2e/protractor.conf.js"]
}
]
}

tasks.json 对此:

{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "start",
"isBackground": true,
"presentation": {
"focus": true,
"panel": "dedicated"
},
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": {
"owner": "typescript",
"source": "ts",
"applyTo": "closedDocuments",
"fileLocation": [
"relative",
"${cwd}"
],
"pattern": "$tsc",
"background": {
"activeOnStart": true,
"beginsPattern": {
"regexp": "(.*?)"
},
"endsPattern": {
"regexp": "Compiled |Failed to compile."
}
}
}
},
]
}

您只需按 F5 即可!

关于VS Code 中的 Angular 调试 - 断点未绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71718090/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com