Angular CLI: 1.7.1
Node: 9.5.0
OS: win32 x64
Angular: 5.2.6
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
@angular/cli: 1.7.1
@angular-devkit/build-optimizer: 0.3.2
@angular-devkit/core: 0.3.2
@angular-devkit/schematics: 0.3.2
@ngtools/json-schema: 1.2.0
@ngtools/webpack: 1.10.1
@schematics/angular: 0.3.2
@schematics/package-update: 0.3.2
typescript: 2.5.3
webpack: 3.11.0
Other:
Yarn 1.3.2
Win 10 Professional x64
Chrome x64 64.0.3282.167
VS Code 1.20.1 x64
VS Code - Debugger for Chrome 4.1.0
VS Code - Debugger for Firefox 1.1.0
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
template: `
<button (click)="onClicked()">TEST</button>
`,
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'app';
onClicked() {
console.log('test');
}
}
{
"name": "Launch Chrome against localhost, with sourcemaps",
"type": "chrome",
"request": "launch",
"url": "http://localhost:4200/",
"runtimeArgs": [
"--user-data-dir",
"--remote-debugging-port=9222"
],
"sourceMaps": true,
"webRoot": "${workspaceRoot}"
}
Nothing happens.
After refreshing the page in chrome, breakpoints sometimes get hit, but VS Code shows them on the wrong line.
Using the Firefox debugger yields the same results.
The breakpoint gets hit in VS Code.
Recent versions <= 1.7.0-beta.1 work as expected
All versions >= 1.7.0-beta.2 do not work (latest checked: v6.0.0-beta.5 / v1.7.3)
We use the same tools on all of our development machines. The observed behavior is the same on every one.
Breakpoints work as expected when set in the webpack sources using chrome dev tools.
Removing the runtimeArgs or webRoot entries from the launch config doesn't help.
Someone posted a similar issue on the VSCode Chrome Debugger repo here.
Using
debugger;
works, see this comment.
I can confirm that this happens with my project too. I have tried both 1.7.0 and 1.7.1 of the CLI and both get mixed up break point in VS Code. After downgrade to 1.6.8 everything works as expected.
I too can confirm the issue. Starting with 1.7.0 breakpoints gets mixed up. Downgrading fixed the problem.
Yeah, here too. Had a hard night pinning it to angular/cli.
Have the same issue.
The same for me: VS Code breakpoints get placed 4 rows lower than the line I've chosen.
Anyway VSCode stops at breakpoints but in read-only tabs only.
Downgrading CLI resolved the issue
Same here - back to 1.6.8 works
Also with version 1.7.2 doesn't work
Confirmed: version 1.6.8 works
VS Code:
Typescript 2.6.2
1.7.0, 1.7.1, 1.7.2 doesn't work
1.6.8 does.
https://github.com/Microsoft/vscode-recipes/issues/81
I'll link that back here.
This is still a issue!
This is not working! Breakpoint changes to the top of the file.
Same problem here...
Same here, sourcemaps are broken in current versions.
Fix: If you use
debugger;
in your typescript code instead if setting a breakpoint, it works, even with sourcemaps and all.
So before 1.7.0-beta.1 , generated sourcemap has full path as root directory
After 1.7.0, generated sourcemap now returns root directory as .
This can be found by accessing Sources tab from Chrome Developer Tools.
@satlom I was able to get debugging working by adding the following source map path override to my configuration in .vscode/launch.json
:
"webpack:/*": "${webRoot}/*"
You can clone https://github.com/mjolka/angular-cli-issue-9729 and then
Ctrl + Shift + B
src/app/app.component.ts:9
F5
Great find mjolka!
I have tried this settings, and it worked with the latest Angular-CLI 1.7.3 and VS Code 1.21.0.
Big thank!!
Worked for me!
While the fix @mjolka describes works for the basic functionality of hitting the breakpoint initially, there are still some pretty substantial issues.
I'm not sure to what extent some of this is VS Code's fault and what of it is Angular's fault, but given that it seemed to start in with 1.7, I'm thinking there's more coming from Angular than from VS Code.
Looked for days for this fix. Works on MacOS, VSCode 1.21.1, Angular CLI 1.7.3
Just changing workspaceRoot to workspaceFolder did not work for me. I had to use mjolka's solution and also add:
"sourceMapPathOverrides": {
"webpack:/": "${webRoot}/"
}
I was somehow able to make this works:
So my use case is that I have a C# project and an Angular project ( Angular project bundled in wwwroot/dist , source is in angularProject )
{
"name": "Attach to Chrome, localhost, with sourcemaps",
"type": "chrome",
"request": "attach",
"port": 9222,
"sourceMaps": true,
// Where the file are bundled, but should work with ng serve as well , as long as you provided the right bundled path
"webRoot": "${workspaceFolder}/src/DotnetProject/wwwroot/dist",
"trace": true,
"sourceMapPathOverrides": {
// The path to my source code
"webpack:///./angularProject/*": "${workspaceFolder}/src/DotnetProject/angularProject/*",
}
}
One good thing to also check the path of the debugging item
and the path of your workspaceFolder
where previously mine was overrides to:
C:/Projects/ProjectA/src/DotnetProject/webapp/webapp/ErrorHandler.ts
which should be
C:/Projects/ProjectA/src/DotnetProject/webapp/ErrorHandler.ts
Using the latest JavaScriptServices with /ClientApp being the root of the angular source I still can't get this working properly. Any suggestions?
I have this issue too and what I did to fix it is:
npm install -g @angular/[email protected]
ng serve
so it will take the global installed version instead of the one used by the project.I really hope someone fix this issue soon.
Some logging I took.
Using angular/cli latest version:
webpack:/src/store/treatment-groups-store.ts (/Users/user/Documents/projects/projectname/src/store/webpack:/src/store/treatment-groups-store.ts)
Using angular/[email protected]
webpack:/src/store/treatment-groups-store.ts (../../src/store/treatment-groups-store.ts)
Please note the differences between paths, this was taken running .scripts
in vscode DEBUG CONSOLE
I have applied many of the comments listed below with no luck.
After some more research this should work with latest cli versions (mine is 1.7.2
):
{
"name": "ng serve",
"type": "chrome",
"request": "launch",
"url": "http://localhost:4200/",
"webRoot": "${workspaceRoot}",
"userDataDir": "${workspaceRoot}/.vscode/chrome",
"sourceMaps": true,
"sourceMapPathOverrides": {
"webpack:/./*": "${webRoot}/*",
"webpack:/src/*": "${webRoot}/src/*",
"webpack:/*": "*",
"webpack:/./~/*": "${webRoot}/node_modules/*"
}
}
@blopez2010 it's working very well, thank you.
Angular CLI: 1.7.4
Node: 8.11.1
OS: win32 x64
Angular: 5.2.9
I have been following this thread since it was also broken on my side and I thought that the latest change from @blopez2010 was working since I was able to hit breakpoints but then I realized that it was hitting indeed but I couldn't get the variables values, so I was just about to revert to 1.6.8
yet again...
...but wait, I found the best solution which is a lot simpler than all other provided in this thread, and it works (hopefully for everyone this time) :)
You really need 2 changes from the original code
webRoot
to "webRoot": "${workspaceFolder}/src"
(or your source folder containing the files)sourceMapPathOverrides
with 1 line in it.Here's my final result
{
"name": "Chrome Debugger",
"type": "chrome",
"request": "launch",
"url": "http://localhost:4200",
"webRoot": "${workspaceFolder}/src",
"sourceMapPathOverrides": {
"webpack:///*": "${webRoot}/*"
}
},
in my case, I don't have /src
but another folder name and so my webRoot
(if my folder is named "mySource") is actually something along
"webRoot": "${workspaceFolder}/mySource",
So just use src
or the name of your folder containing, well your source files. You may also want to add the userDataDir
but that is totally optional, if so use something along this "userDataDir": "${workspaceFolder}/.chrome",
And voil脿!
I finally have breakpoints working and ready for Angular 6.x :)
How did I get the map path override? Simple, start the debugger in VSCode and in the "Debug Console" terminal window, type .scripts
and see what path you need for updating the sourceMapPathOverrides
Actually with new VSCode version 1.23.0
everything back to normal with just
{
"name": "ng serve",
"type": "chrome",
"request": "launch",
"url": "http://localhost:4200/",
"webRoot": "${workspaceRoot}",
"userDataDir": "${workspaceRoot}/.vscode/chrome",
"sourceMaps": true
}
I don't like magic but... it is working now.
@ghiscoding: Fails for me. I even closed and reopened VSCode. (Using VSCode 1.23.0)
@blopez2010: Yours mostly works. But, in this example:
getList(): void {
this.loading = true;
this.service.getAll("parentId", this.parentId ? this.parentId.toString() : null).then(data => {
this.list = data;
this.processList();
});
}
With a breakpoint on LINE 5 (this.processList();
), this.list
on LINE 4 is undefined
. So is this
on LINE 4.
Is that expected?
@kdubious , have you checked whether it's undefined
in Chrome DevTools Debugger as well? Sometimes Chrome Debugger is unable to properly resolve sourcemapped this
to _this
in closures in generated JS. You can easily check it by temporary disabling Sourcemaps in Chrome.
If it's undefined
there as well, then it's not the issue with VS Code.
As @AbakumovAlexandr says @kdubious, this
within then
promise is in a different scope than higher one, because of that you see it as undefined
and this isn't an error since in Chrome DevTools happens in same way, actually with new feature, adding Log Message on breakpoints, you could see the value that is being set to this.list
or creating a temporary variable to set this.list
before its assignment.
Heya, I tried testing this today using Angular CLI 6.0.5.
These were the steps I took:
src/app/app.component.ts
with:import { Component } from '@angular/core';
@Component({
selector: 'app-root',
template: `
<button (click)="onClicked()">TEST</button>
`,
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'app';
onClicked() {
console.log('test');
}
}
ng serve
.DEBUG
dropdown, clicked Add Configuration
.{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:4200",
"webRoot": "${workspaceFolder}"
}
]
}
TEST
button in the Angular app, debugger is not triggered.Sources
tab.webpack://./src/app/app.component.ts
and added a breakpoint to line 14 (console.log('test');
by clicking on the line number.TEST
button in the Angular app. The breakpoint was hit. It looks like breakpoints defined inside Chrome work.src/app/app.component.ts
inside VS code and added a breakpoint to line 14 by clicking on the line.TEST
button in the Angular app. The breakpoint was hit. It looks like breakpoints defined inside VSCode work.debugger;
statement in line 14.TEST
button in the Angular app. The breakpoint was hit. It looks like breakpoints defined via debugger;
statements work.It looks like right now all of these work with the default configuration provided by the Chrome debugger in VS Code.
I am not sure what changed, or why they did not work before, but it seems ok now.
Actually, I have an idea of what might have changed. At some point we used eval-source-map
which adds sourcemaps into the JS code directly, and evaluates them using eval
. This makes rebuilds faster.
I don't think we're using them anymore. Maybe that was why.
same issue on 6.0.5 not sure if the chrome tool
yes, same issue with Chrome Debugger 4.9 VS Code Extension.
and angular cli 6.1.4
Hi,
We are having a very similar problem. I posted a description of it here.
Would appreciate you taking a look at it.
Thanks,
Dan
Hi, I'm also having issues in debugging. The debugger doesn't stop at breakpoint in VSCode. However, VS Code debugging works when I put a break point in the Chrome DevTools itself. Here's my launch settings and sources in Chrome:
Nevermind, I actually managed to get it working by just copy & pasting the sourceMapPathOverrides from the vs-code-chrom-debugger docs: https://github.com/Microsoft/vscode-chrome-debug#sourcemaps
Hi,
Debugger works when running ng serve
.
I don't need to set sourceMapPathOverrides, userDataDir or sourceMaps in the lauch configurations.
But debugger does not work when running ng test
.
To fix it :
ng test --source-map=false
. {
"name": "ng serve",
"type": "chrome",
"request": "launch",
"url": "http://localhost:4200/#",
"webRoot": "${workspaceFolder}"
},
{
"name": "ng test",
"type": "chrome",
"request": "launch",
"url": "http://localhost:9876/debug.html",
"webRoot": "${workspaceFolder}"
}
vscode 1.29
Angular CLI: 7.1.0
Node: 8.14.0
OS: linux x64
Angular: 7.1.1
For people who are not able to get breakpoints work
Use the workaround
debugger
text as this works even though breakpoints don't work
This is the configuration that works for me:
{
"name": "ng serve",
"type": "chrome",
"request": "launch",
"url": "http://localhost:4200",
"webRoot": "${workspaceFolder}",
"sourceMaps": true,
"trace": true,
"userDataDir": "${workspaceFolder}/.vscode/chrome",
"sourceMapPathOverrides": {
"webpack:///./~/*": "${webRoot}/node_modules/*",
"webpack:///./*": "${webRoot}/*",
"webpack:///*": "*",
"webpack:///src/*": "${webRoot}/*"
}
},
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
@satlom I was able to get debugging working by adding the following source map path override to my configuration in
.vscode/launch.json
:You can clone https://github.com/mjolka/angular-cli-issue-9729 and then
Ctrl + Shift + B
src/app/app.component.ts:9
F5