question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sourcemaps generated by all versions >= 1.7.0-beta.2 do not work in the VS Code Chrome/Firefox Debuggers

See original GitHub issue

Versions

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

Repro steps

  • ng new
  • Add some test code:
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
  • Start debugging using this config:
{
   "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}"
 }
  • Set a breakpoint on the button click handler
  • Click button

Observed behavior

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.

Desired behavior

The breakpoint gets hit in VS Code.

Mention any other details that might be useful (optional)

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.

Workaround

Using

debugger;

works, see this comment.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:22
  • Comments:39 (2 by maintainers)

github_iconTop GitHub Comments

23reactions
mjolkacommented, Mar 15, 2018

@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
  • Set a breakpoint in src/app/app.component.ts:9
  • Hit F5
  • Refresh the page and the breakpoint should be hit
8reactions
satlomcommented, Mar 8, 2018

This is still a issue!

  • Installed VS Code 1.21.0 x64.
  • latest angular/cli 1.7.3.
  • Created a new project with “ng new testcli”.
  • Set a breakpoint in app.component.ts on title = “app”;
  • Create a launch.json to use Chrome debugging and change port to 4200.
  • ng serve
  • F5 to start debugging anf launch Chrome

This is not working! Breakpoint changes to the top of the file.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeScript debugging with Visual Studio Code
TypeScript debugging supports JavaScript source maps. To generate source maps for your TypeScript files, compile with the --sourcemap option or set the ...
Read more >
Debug with Visual Studio Code not working - Stack Overflow
I was able to solve this problem on OSX. The reason it's such a pain is there are multiple things causing the issue....
Read more >
Debugging in VS Code - Vue.js
This recipe shows how to debug Vue CLI applications in VS Code as they run in the browser. Note: This recipe covers Chrome...
Read more >
Using Phaser with Visual Studio Code | Damian Connolly
The only thing I would say, is set sourceMap to true if you want to generate sourcemaps for your compiled JS, which lets...
Read more >
Debugging AngularJS from VS Code with Docker Containers
The docker build calls npm install as one of its final steps, but the older version of npm it is running does not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found