Chrome Devtools专用的Node.js检查器不会在断点处停止 [英] Chrome Devtools Dedicated Node.js Inspector not stopping at breakpoints

查看:53
本文介绍了Chrome Devtools专用的Node.js检查器不会在断点处停止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于此问题有一些较旧的帖子,但是从2013年和2014年提出的问题来看,那里的答案对我的情况没有帮助.

There have been a couple of older posts regarding this issue, but date from questions asked in 2013 and 2014 and the answers in there have not helped my case.

我在文件的多个位置放置了debugger关键字,甚至在检查器UI中添加了手动断点.尽管如此,执行文件不会在任何断点处停止.我正在使用节点9.2.0和chrome 64.0.3282.167.

I have the debugger keyword placed in multiple places in my file, and have even added manual breakpoints in the inspector UI. Still, executing the file does not stop at any breakpoints. I am using node 9.2.0 and chrome 64.0.3282.167.

这是我的devtools外观的图片.

Here is a picture of how my devtools appears.

推荐答案

改用--inspect-brk标志

我最终在 devtools协议github页面上提出了一个问题.

Use the --inspect-brk flag instead

I ended up opening up an issue on the devtools protocol github page.

我得到了立即答复.基本上,因为我使用的是--inspect标志来启动Node.js调试器,所以在调试器进程连接到DevTools服务器之前就已经执行了我的JavaScript.因此,断点信息将传递得太晚,并且不会触发任何断点.

I got an immediate answer. Basically, because I was using the --inspect flag to start the Node.js debugger, my JavaScript was being executed before the debugger process was connecting to the DevTools server. Therefore breakpoint information would be relayed too late and no breakpoints would be triggered.

示例:node --inspect-brk myscript.js

他们目前正在尝试改进此用例.这是实际的答复:

They're currently trying to improve this use case. Here's the actual reply:

我们在这里致力于改善工作流程,但现在--inspect-brk 只有一种方法.使用--inspect-brk节点等待DevTools前端 联系.连接时,DevTools发送所有断点信息 并在节点中开始执行JavaScript.用--inspect节点启动 无需等待DevTools前端即可执行JavaScript.立刻 DevTools已连接,我们将相同的断点信息发送到节点 但是可能已经为时已晚,因为已经执行了一些JavaScript.

We are working on better workflow here but for now --inspect-brk is only one way. With --inspect-brk node waits DevTools frontend connection. On connection DevTools send all breakpoints information and starts JavaScript execution in node. With --inspect node starts JavaScript execution without waiting for DevTools frontend. As soon as DevTools connected, we send the same breakpoint information to node but it can be too late since some JavaScript is already executed.

截至2018年6月4日,Node.js文档在这种微妙之处上还不是很清楚.我将针对他们的回购提交PR,以更新文档.顺便说一句,如果您不知道,即使没有V8集成,内置调试器也非常强大.在文档中探索调试实用程序的所有可能性.

The Node.js docs are not very clear on this subtlety as of 4/6/2018. I will submit a PR on their repo to update the docs. BTW, if you are not aware, even without the V8 integration, the built-in debugger is very powerful. Explore all the possibilities of the debugging utility in the docs.

这篇关于Chrome Devtools专用的Node.js检查器不会在断点处停止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆