Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unbound breakpoint - VS Code | Chrome | Angular

I have an Angular application that I am trying to debug in VS Code.

When I compile and run the application (ng serve) the breakpoints are bound:

enter image description here

However, when I specify a different configuration e.g. -c qa or -c uat they are unbound:

enter image description here

  1. Why are the breakpoints unbound when I specify a different configuration?
  2. How do I bind the breakpoints for a debug session targeting a particular environment?

Relevant information

angular.json sample environment configuration:
"uat": {   "fileReplacements": [     {       "replace": "src/environments/environment.ts",       "with": "src/environments/environment.uat.ts"     }   ],   "optimization": true,   "outputHashing": "all",   "sourceMap": false,   "extractCss": true,   "namedChunks": false,   "extractLicenses": false,   "vendorChunk": false,   "buildOptimizer": true,   "budgets": [     {       "type": "initial",       "maximumWarning": "2mb",       "maximumError": "5mb"     },     {       "type": "anyComponentStyle",       "maximumWarning": "6kb",       "maximumError": "10kb"     }   ] }, 
Software versioning:
  • Visual Studio Code 1.50.1
  • Chrome 83.0.4103.122
  • Debugger for Chrome 4.12.11
  • JavaScript Debugger (Nightly) 2020.10.2217
like image 677
Jaa H Avatar asked Oct 29 '20 10:10

Jaa H


People also ask

How do I skip a breakpoint in Visual Studio?

And when debugging, enabled breakpoints can be individually skipped. But within Visual Studio, there is no means to skip all enabled breakpoints. To effectively skip all breakpoints, one must disable all of them, but disabling also requires they be re-enabled individually.

How do you keep breakpoint in Visual Studio code?

To set a breakpoint in source code, click in the far left margin next to a line of code. You can also select the line and press F9, select Debug > Toggle Breakpoint, or right-click and select Breakpoint > Insert breakpoint.

Why is my breakpoint not working Vscode?

If a source file has changed and the source no longer matches the code you're debugging, the debugger won't set breakpoints in the code by default. Normally, this problem happens when a source file is changed, but the source code wasn't rebuilt. To fix this issue, rebuild the project.


2 Answers

The fix for this was simple, I hadn't set the sourceMap property to true in angular.json for that particular environment, instead I had "sourceMap": false,

See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/SourceMap for more info.

With thanks to Connor - https://github.com/microsoft/vscode-js-debug/issues/872

like image 62
Jaa H Avatar answered Sep 16 '22 12:09

Jaa H


In my case I needed to change webroot

FROM

"webRoot": "${workspaceFolder}"

TO "webRoot": "${workspaceFolder}\projectName"

Project name is the name you've given in the beginning ng new projectName

Then breakpoint bound.

like image 24
Davut Gürbüz Avatar answered Sep 18 '22 12:09

Davut Gürbüz