简体   繁体   English

用于节点在非断点处停止的WebStorm调试器

[英]WebStorm Debugger for Node Stopping at Non Breakpoints

In WebStorm, I have a Node application and I simply hit debug and on load the debugger stops on a bunch of seemingly random lines in node_modules. 在WebStorm中,我有一个Node应用程序,我只是点击调试并在加载时调试器在node_modules中的一堆看似随机的行上停止。 I can continue through about 5 files until I get to a router/index.js file that gets stuck on a single line for countless continues. 我可以继续浏览大约5个文件,直到我找到一个路由器/ index.js文件,这个文件卡在一行上无数次继续。

I have no breakpoints in any of the node_modules files, obviously, and WebStorm does not show a breakpoint. 显然,我在任何node_modules文件中都没有断点,并且WebStorm不显示断点。 However it stops every time. 然而它每次都停止。 My solution has been to mute all breakpoints, wait for the app to load, and then unmute. 我的解决方案是将所有断点静音,等待应用程序加载,然后取消静音。 Sometimes, though, I have to re-add my breakpoints if I want the checkbox to check and be able to hit those breakpoints. 但是,有时候,如果我想检查复选框并能够点击那些断点,我必须重新添加断点。 At this point I have no issues. 在这一点上,我没有问题。 Any idea why it's getting stuck in node_modules with no breakpoints? 知道为什么它会陷入没有断点的node_modules吗?

Figured out a workaround. 想出了一个解决方法。 I chose "view breakpoints" and although the points that were consistently stopped at were not listed, I simply removed all breakpoints, and I can now debug without stopping in random node_modules. 我选择了“查看断点”,虽然没有列出一直停留的点,但我只是删除了所有断点,现在我可以在不停止随机node_modules的情况下进行调试。

Sometimes a file may have hidden chars in it that confuses the parser, and setting a breakpoint in your primary file causes a break at a random line. 有时文件中可能包含隐藏的字符会使解析器混乱,并且在主文件中设置断点会导致随机行中断。

to determine if you have hidden chars open vi alongside the webstorm view of same file. 确定你是否有隐藏的字符与同一文件的webstorm视图一起打开vi。

in vi... 在...中...

:set list
:set number

from the top of the file scroll down looking at the end of each line to see if the $ isn't where you think it should be when moving down the same line in Webstorm editor. 从文件顶部向下滚动,查看每一行的结尾,看看在Webstorm编辑器中向下移动同一行时,$是不是您认为应该是的位置。

if you find something like... 如果你发现像......

let j = 'hello' $

in the vi view, but see 在vi视图中,但看到

let j = 'hello'^

^ being your cursor in webstorm, delete from the cursor one char. ^是你在webstorm中的光标,从光标删除一个char。 It will not move, keep going until the first visible char is deleted, then put it back, move to the next occurrence. 它不会移动,继续运行,直到删除第一个可见的字符,然后将其放回,移动到下一个出现。

I ran into a similar issue in Webstorm 2017.2.4 while debugging clusters and workers. 在调试集群和工作人员时,我在Webstorm 2017.2.4中遇到了类似的问题。 I have a file named worker.js and a number of breakpoints in it. 我有一个名为worker.js的文件和一些断点。 When I debug through Webstorm, the debugger is pulling up every file it can find named worker.js and breaking on the same line number as marked in the "real" worker.js . 当我通过Webstorm进行调试时,调试器会提取它找到的名为worker.js 每个文件,并打破与“real” worker.js标记的相同行号。

The only workaround right now is to rename the file while debugging it. 现在唯一的解决方法是在调试文件时重命名该文件。

I've also encountered this problem and solved it by moving entrypoint code to another file, for example "lib/main.js". 我也遇到了这个问题并通过将入口点代码移动到另一个文件来解决它,例如“lib / main.js”。

index.js : index.js:

module.exports = require('./lib/main');

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

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