"configurations": [
{
"name": "Attach to Edge",
"port": 9222,
"request": "attach",
"type": "pwa-msedge",
"webRoot": "${workspaceFolder}"
}
启动 msedge.exe --remote-debugging-port=9222
我收到以下错误
您使用的是哪个版本的 JavaScript 调试器和 Edge 浏览器?我使用 JavaScript 调试器 v1.57.0 和 Edge 浏览器版本 91.0.864.59 进行测试,效果很好。
在开始在 VS Code 中调试之前,您是否先在 Edge 中启动了要调试的页面?
"request": "attach"
表示将调试附加到现有实例。例如,我需要调试此页面https://localhost:44364/test.html
,然后我将在start msedge.exe --remote-debugging-port=9222
之后在Edge中导航到此网址。结果是这样的:
更新:
如果您使用的是 Microsoft Edge 调试器,您可以使用如下所示的
launch.json
,然后按照我在上一个答案中所说的操作:
{
"version": "0.2.0",
"configurations": [
{
"type": "edge",
"request": "attach",
"name": "Attach to Edge",
"port": 9222,
"webRoot": "${workspaceFolder}"
}
]
}
注意: 请安装最新版本的 Visual Studio。 VS 版本 >= 15.9.19 支持调试 Microsoft Edge (Chromium)。
启动 msedge.exe --remote-debugging-port=9222
安装 [适用于 VSCode 的 Microsoft Edge Tools][1]。
在.vscode中使用这个launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "msedge",
"name": "Launch Microsoft Edge",
"request": "launch",
"cleanUp": "wholeBrowser",
"cascadeTerminateToConfigurations": [
"Open Edge DevTools"
],
"url": "http:localhost:3000",
"presentation": {
"hidden": true
}
},
{
"type": "msedge",
"name": "Launch Microsoft Edge in headless mode",
"request": "launch",
"runtimeArgs": [
"--headless",
"--remote-debugging-port=9222"
],
"url": "http:localhost:3000",
"presentation": {
"hidden": true
}
},
{
"type": "vscode-edge-devtools.debug",
"name": "Open Edge DevTools",
"request": "attach",
"url": "http:localhost:3000",
"presentation": {
"hidden": true
}
}
],
"compounds": [
{
"name": "Launch Edge Headless and attach DevTools",
"configurations": [
"Launch Microsoft Edge in headless mode",
"Open Edge DevTools"
],
"stopAll": true
},
{
"name": "Launch Edge and attach DevTools",
"configurations": [
"Launch Microsoft Edge",
"Open Edge DevTools"
],
"stopAll": true
}
]
}