How to debug Angular application in VSCode using Edge browser? 我在这里尝试了建议,但均无济于事。 我本来是对最后一个答案发表评论的,但我没有50的声誉,回答一个问题是不礼貌的,所以在这里我要问另一个问题。
以上主题中的两个launch.json建议无效,“ Debugger for Edge”自动生成的launch.json也无效。 我分别尝试了一下都无济于事(见下文)
{
"version": "0.2.0",
"configurations": [
{
"type": "edge",
"request": "launch",
"name": "Launch Edge against localhost(Debugger for Edge)",
"url": "http://localhost:4200",
"webRoot": "${workspaceFolder}"
}
]
}
{
"version": "0.2.0",
"configurations": [
{
"name": "debug edge (Answer 1 from topic, I removed the things about Chrome was I wouldn't use that browser)",
"type": "edge",
"request": "launch",
"url": "http://localhost:4200/#",
"webRoot": "${workspaceFolder}",
"sourceMapPathOverrides": {
"webpack:/./*": "${webRoot}/*",
"webpack:/src/*": "${webRoot}/src/*",
"webpack:/*": "*",
"webpack:/./~/*": "${webRoot}/node_modules/*"
},
},
{
"name": "ng e2e",
"type": "node",
"request": "launch",
"program": "${workspaceFolder}/node_modules/protractor/bin/protractor",
"protocol": "inspector",
"args": ["${workspaceFolder}/protractor.conf.js"]
}
]
}
{
"version": "0.2.0",
"configurations": [
{
"name": "Edge (Answer 2 from topic)",
"type": "edge",
"request": "launch",
"url": "http://localhost:4200/#",
"webRoot": "${workspaceFolder}",
"sourceMaps": true,
"trace": true,
"userDataDir": "${workspaceRoot}/.vscode/edge"
}
]
}
浏览器启动,并显示页面(应用程序),但未命中断点。在VSCode中,红点变为空心圆。
上面的launch.json应该放在单独的代码块中,但是编辑器不允许我使用
标记。
答案 0 :(得分:0)
首先,请检查您的VSCode版本,如下所示:我的VSCode版本:
而且,我的角度版本是:Angular 7.1.4。
要调试客户端Angular代码,我们需要先安装Edge扩展调试器。
在VSCode上,单击视图菜单,然后选择扩展选项以检查是否已安装Debugger for Edge扩展并已启用它。然后,按Reload重新启动VS Code并激活扩展程序。
在typescript类中设置断点后,转到“调试”视图并添加调试配置:
保存更改并选择调试环境后,您可以按F5调试代码,如下所示: