Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug Angular 6 subproject from VS Code

I Created a new Angular 6 CLI project

ng new myProjects

Created 'sub project'

ng g mySubProject

If I ng serve mySubProject then try to debug from VS Code using my normal launch.json, then breakpoints are not hit.

{
  "name": "Launch Chrome (test)",
  "type": "chrome",
  "request": "launch",
  "url": "http://localhost:4200/",
  "webRoot": "${workspaceFolder}"
},

Can someone guide me how to set up my launch.json to debug sub-projects like this?

(for details on how I have my sub projects set up, it's based on a post here )

If I just ng serve, then this launch.json debigs the 'main' project OK - so I am guessing I need to set up somewhere in the launch.json to tell it where the child project is?

like image 866
Maxxx Avatar asked May 15 '18 23:05

Maxxx


People also ask

How do I debug in angular8?

You can see a “Debug” button in the left side bar of visual studio code. Please click that button. It will automatically create a new “launch.

How do I open an existing Angular Project in Visual Studio Code using CMD?

Now open Visual Studio Code. Go to "File" > "Open Folder" and select "First-Angular-Project" from the "Desktop". Now in the "TERMINAL" run ng new Angular-Project-Demo. Whenever it prompts with something like "Would you like to add Angular routing? (y/N)" press "y" and hit "ENTER".

How do I debug console in VS code?

Launch configurations. To run or debug a simple app in VS Code, select Run and Debug on the Debug start view or press F5 and VS Code will try to run your currently active file.


1 Answers

To debug a sub-project in an Angular 6.0 workspace: Set your launch.json configuration to look like:

{
  "name": "ng serve my sub application",
  "type": "chrome",
  "request": "launch",
  "url": "http://localhost:4200",
  "webRoot": "${workspaceRoot}/projects/mysubapplication"
}

This means you will need a configuration entry for every sub application.

like image 129
Maxxx Avatar answered Sep 29 '22 19:09

Maxxx