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:
However, when I specify a different configuration e.g. -c qa
or -c uat
they are unbound:
"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" } ] },
1.50.1
83.0.4103.122
4.12.11
2020.10.2217
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.
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.
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.
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With