如何在VS Code中通过附加到Edge浏览器进行调试?已完成配置但出现错误
Hey there! Let’s work through fixing the error you’re hitting with your Edge debugger setup in VS Code. First, let’s recap what you’ve already configured correctly:
Your Current Setup
- You’ve installed the Edge JavaScript Debugger extension in VS Code
- Your
launch.jsonincludes this attach configuration:
"configurations": [ { "name": "Attach to Edge", "port": 9222, "request": "attach", "type": "pwa-msedge", "webRoot": "${workspaceFolder}" } ]
- You launched Edge with remote debugging enabled using this command:
start msedge.exe --remote-debugging-port=9222
Common Fixes for Attach Errors
Since you didn’t share the exact error message, here are the most frequent issues and their quick fixes:
1. Check for Port Conflicts
Port 9222 might be used by another app. Open Command Prompt and run this to check:
netstat -ano | findstr :9222
If you see a process ID (PID), open Task Manager, find that process, end it, then restart Edge with the remote debugging flag.
2. Use a Dedicated Debug Profile
Edge might be launching with your main profile, which can cause conflicts. Try starting Edge with a fresh, debug-only profile:
start msedge.exe --remote-debugging-port=9222 --user-data-dir="C:\Temp\EdgeDebugProfile"
This avoids any settings or extensions in your regular profile interfering with debugging.
3. Verify the webRoot Path
The ${workspaceFolder} variable points to the root folder you have open in VS Code. If your web files (HTML/JS) are in a subfolder like src, update webRoot to match:
"webRoot": "${workspaceFolder}/src"
Double-check that the path matches where your actual code lives.
4. Kill Edge Background Processes
Even if you closed Edge, it might still run in the system tray. Right-click the Edge icon there and select "Exit" before launching it with the debug command again.
5. Restart VS Code and the Debugger
Sometimes the extension gets stuck. Close VS Code entirely, restart it, launch Edge with the debug flag, and try attaching the debugger again.
If none of these work, sharing the exact error text from the VS Code Debug Console or Problems tab will help us pinpoint the issue even better!
内容的提问来源于stack exchange,提问作者Harkirat singh

