简体   繁体   English

调试到angular 2打字稿源代码

[英]debugging into angular 2 typescript source code

I have an angular2 project generated by angular-cli. 我有一个由angular-cli生成的angular2项目。 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). 我希望能够在chrome dev工具中调试angular2 typescript源代码(不是我自己的打字稿代码,而是实际的angular2代码)。 The angular2 npm package under node_modules only contains the transpiled javascript files but they contain source mappings. node_modules下的angular2 npm包只包含已转换的javascript文件,但它们包含源映射。 How can I make this work? 我怎样才能做到这一点? Thx. 谢谢。

How about putting debugger; debugger;怎么样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. 在您要调试的位置,这将触发chrome dev工具中的断点,您可以从那里开始工作。

Open chrome developer tool (F12). 打开镀铬开发工具(F12)。

Go to Source tab. 转到“源”选项卡。 Enter ctrl+p . 输入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. 然后继续执行调用要调试的行的操作。

显然,这在angular-cli中是不可能的,因为它们忽略了node_modules中的源映射( https://github.com/angular/angular-cli/issues/1838 )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM