如何配置VS Code使用基于Chromium的Opera调试Angular 2项目
Absolutely! Since Opera is built on the Chromium engine, you can leverage the Debugger for Chrome extension you already have to debug your Angular 2 project in Opera with just a few simple configuration changes. Here's how to set it up:
Step 1: Enable Remote Debugging in Opera
First, you need to launch Opera with remote debugging enabled—this lets VS Code connect to the browser for debugging:
- Windows: Run this command (adjust the path if your Opera installation is in a different location):
"C:\Program Files\Opera\launcher.exe" --remote-debugging-port=9222 - macOS: Use this terminal command:
/Applications/Opera.app/Contents/MacOS/Opera --remote-debugging-port=9222 - Linux: Run:
opera --remote-debugging-port=9222
Pro tip: Create a desktop shortcut or alias with this command to avoid typing it every time you need to debug.
Step 2: Update Your launch.json Configuration
You have two flexible options here—either launch Opera directly from VS Code, or attach to an already running Opera instance with remote debugging enabled.
Option 1: Launch Opera from VS Code
Modify your existing launch.json to point to Opera's executable and enable remote debugging:
{ "version": "0.2.0", "configurations": [ { "name": "Launch Opera against localhost", "type": "chrome", "request": "launch", "url": "http://localhost:4200", "webRoot": "${workspaceFolder}", "runtimeExecutable": "opera", // Use full path if Opera isn't in your system PATH (e.g., "C:\\Program Files\\Opera\\launcher.exe" for Windows) "runtimeArgs": ["--remote-debugging-port=9222"] } ] }
Option 2: Attach to a Running Opera Instance
If you prefer to manually launch Opera with remote debugging first, use this attach configuration instead:
{ "version": "0.2.0", "configurations": [ { "name": "Attach to Opera", "type": "chrome", "request": "attach", "url": "http://localhost:4200", "webRoot": "${workspaceFolder}", "port": 9222 } ] }
Step 3: Start Debugging
- Make sure your Angular project is running with
ng serve(it should be accessible athttp://localhost:4200). - In VS Code, select your new Opera debugging configuration from the run dropdown.
- Start the debugger—Opera will launch (or VS Code will attach to your running instance), and you can set breakpoints, inspect variables, and debug your Angular code just like you would in Chrome.
内容的提问来源于stack exchange,提问作者rostamiani




