问题
I have an angular2 project generated by angular-cli. I want to be able to debug the angular2 typescript source code in chrome dev tools (not my own typescript code but the actual angular2 code). The angular2 npm package under node_modules only contains the transpiled javascript files but they contain source mappings. How can I make this work? Thx.
回答1:
How about putting debugger;
at the location you want to debug, this will trigger a breakpoint in chrome dev tools and you can work your way from there.
回答2:
Open chrome developer tool (F12).
Go to Source tab. Enter ctrl+p
.
Search the file name in the drop-down.
Select the file and add break point at the line which you want to debug.
And proceed your actions which calls the line which you want to debug.
回答3:
Apparently, this is not yet possible in angular-cli since they ignore source maps in node_modules (https://github.com/angular/angular-cli/issues/1838).
来源:https://stackoverflow.com/questions/40437909/debugging-into-angular-2-typescript-source-code