📅  最后修改于: 2023-12-03 15:13:23.491000             🧑  作者: Mango
Debugging Angular applications in Google Chrome browser can be a daunting task, especially when you have a complex codebase. The launch.json
file used in Visual Studio Code can help to streamline the process and make debugging a lot easier.
This guide will take you through the process of setting up your Angular project for debugging using the launch.json
file in Visual Studio Code.
Before you begin, make sure you have the following installed:
launch.json
Ctrl+Shift+D
.Add Configuration
and select Chrome
from the dropdown list.launch.json
file to include the following configuration settings:{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Chrome against localhost",
"type": "chrome",
"request": "launch",
"url": "http://localhost:4200",
"webRoot": "${workspaceFolder}"
},
{
"name": "Attach to Chrome",
"type": "chrome",
"request": "attach",
"port": 9222,
"webRoot": "${workspaceFolder}"
}
]
}
Launch Chrome against localhost
configuration launches a new instance of Google Chrome browser and connects to the Angular application running on localhost at port 4200.Attach to Chrome
configuration lets you attach the Google Chrome browser instance to Visual Studio Code for debugging purposes.ng serve
in your terminal or command prompt.Ctrl+Shift+D
.Launch Chrome against localhost
from the dropdown configuration menu.Play
button to start the debugger.Debugging Angular applications in Google Chrome browser can be made easier by setting up the launch.json
file in Visual Studio Code. With this configuration, you can easily connect to your Angular application running on localhost and set breakpoints in your code to debug it.