I\'m using the Chrome Debugger plugin in Visual Studio Code to debug an Angular application. After upgrading to use angular/cli@1.7.0, we can no longer hit breakpoints in t
Yes, same thing here.
Sometimes I can reach the breakpoint I want with some difficulty (the issue seems to be with the sourcemap, but the debugger is still functional).
I tried fiddling with some settings in the VS-Code debugger launch configuration ("sourceMaps" and "trace"), but to no avail.
Eventually I rolled back @angular/cli to 1.6.8 and it works fine again.
Edit: Forgot to mention, in case it helps someone searching for this issue - when starting debugging, the breakpoints disappear from the source file and its tab is marked with "read-only inlined content from source map".
Also, @angular/cli 1.7.1 does not resolve this.
Angular CLI 7.2.2:
Webstorm/Intellij - breakpoints never hit, VSCode - breakpoints unverified/never hit, Chrome debugger - breakpoints hit perfectly.
Solution: in angular.json set evalSourceMap to "false".
This triggers the Webpack that Angular CLI uses under the hood to generate source maps to original source code ("source-map") instead of generated code ("eval"). https://webpack.js.org/configuration/devtool
See under node_modules@angular-devkit\build-angular\src\angular-cli-files\models\webpack-configs\browser.js
You can of course hack the browser.js file to set some other value for devtool.
For those coming across this the fix is to modify your launch.json sourceMapPathOverrides as follows:
"sourceMapPathOverrides": {
"webpack:/*": "${webRoot}/*"
}
This fixed it for me with the latest @angular/cli (version 1.7.3).
Answer was found here.
If you are using a WorkSpace with 1 or more Projects..
Working for me: launch.json
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "ng serve",
"url": "http://localhost:4300",
"webRoot": "${workspaceFolder}/ProjectName",
"sourceMapPathOverrides": {
"webpack:/*": "${webRoot}/*"
}
}
]
1- Start Project ng serve --port 4300
2- Start Debugging
Setting sourceMapPathOverrides was not sufficient.
In my case the index.html file is located in "/src", and Angular components in "/src/app". I use @angular/cli 1.7.4, vscode 1.22.2 and chrome debugger 4.3.0.
I had to set three parameters in the launch.json.
"sourceMapPathOverrides": {
"webpack:/*": "${webRoot}/*"
},
"webRoot": "${workspaceFolder}",
"sourceMaps": true,
sourceMaps is optional but make sure it is not set to false.
It must be set for each configuration of the launch.json config file:
{
"version": "0.2.0",
"configurations": [
{
"name": "Chrome DEBUG 172.22.44.49",
...
In the chrome debugger sourcemaps documention, It is said to set webRoot to the directory that files are served from. But to solve this issue I had to set it to the workspace root directory.
Same here, rolled back to 1.6.8 (and angular 5.1.1) to get my breakpoints working again.