简体   繁体   English

Webstorm 调试器断点在 nodejs 中不起作用

[英]Webstorm debugger breakpoints doesn't work in nodejs

When I try to set a breakpoint and debug the file, the debugger just run the app without stopping at breakpoints.当我尝试设置断点并调试文件时,调试器只是运行应用程序而不会在断点处停止。 This is my code:这是我的代码:

console.log('123');

And this is my output:这是我的 output:

/usr/bin/node --debug-brk=39765 --nolazy index.js
debugger listening on port 39765
123

Process finished with exit code 0

Does anyone has an idea what could be the problem?有谁知道可能是什么问题?

Try to disable js.debugger.v8.use.any.breakpoint in WebStorm registry.尝试在WebStorm注册表禁用js.debugger.v8.use.any.breakpoint。

You can do it by going to Help -> Find Action您可以通过转到“帮助” ->“查找操作”来完成

In there just enter Registry .在那里输入Registry

For me disabling this option made debugging anything node-related much faster and much more predictable.对我来说,做出禁止任何调试此选项节点相关的更快和更具可预测性。

Wanted to chime in and say that it is absolutely critical that you use --debug-brk and not --debug with getting WebStorm breakpoints to work for remote debugging as well as running the server directly from webstorm.想插嘴说,使用--debug-brk而不是--debug来让 WebStorm 断点用于远程调试以及直接从 webstorm 运行服务器是绝对重要的

Even though --debug-brk technically just stops and waits for the debugger to join, and --debug allows you to join later, my breakpoints failed with just --debug no matter the remote configuration I tried.尽管--debug-brk技术上只是停止并等待调试器加入,并且--debug允许您稍后加入,但无论我尝试了--debug远程配置,我的断点都因--debug失败。

As far as I can tell, connecting WebStorm 11 to a node.js server on the debug port, with only --debug , will connect but fail to load any breakpoints that work.据我所知,仅使用--debug将 WebStorm 11 连接到调试端口上的 node.js 服务器将连接但无法加载任何有效的断点。

Debug breakpoints not work in my PhpStorm 2016.3.2 with NodeJS 7.7.x.使用 NodeJS 7.7.x 在我的 PhpStorm 2016.3.2 中调试断点不起作用。 My expectation is, that WebStorm will have same issue.我的期望是,WebStorm 会有同样的问题。

If you downgrade to Node 6 (I tested with 6.9.4), it starts working correctly.如果你降级到 Node 6 (我用 6.9.4 测试过),它就会开始正常工作。

For me the issue was that WebStorm didn't play well with my typescripts.对我来说,问题是 WebStorm 不能很好地与我的打字稿配合使用。 It would say debugger listening and then run through the entire program without stopping at the breakpoint as described in the question.它会说调试器正在侦听,然后运行整个程序,而不像问题中描述的那样在断点处停止。

The workaround I used was to simply put the breakpoint in compiled js file and debug from there instead.我使用的解决方法是简单地将断点放在已编译的 js 文件中,然后从那里进行调试。

  1. Go to Run -> View Breakpoints... or hit shift + command + F8 in OS X.转到Run -> View Breakpoints...或在 OS X 中shift + command + F8
  2. Select your breakpoint from the list and make sure Suspend is checked.从列表中选择您的断点并确保已选中Suspend

启用暂停

Fixed the issue by enabling generation of 'map' file in the TypeScript configuration.通过在 TypeScript 配置中启用“地图”文件的生成来修复该问题。 Add '--sourceMap' in Tools-->Languages & Frameworks-->TypeScript-->Options在工具-->语言和框架-->TypeScript-->选项中添加'--sourceMap'

I'm having the same issue in version 2022.2 but I don't think it is a problem with the version我在 2022.2 版中遇到了同样的问题,但我认为这不是版本问题

Here are the potential solutions;这是潜在的解决方案;


Go to; Go转;

WebStorm -> Preference -> Build, Execution, Deployment -> Debugger WebStorm -> 首选项 -> 构建、执行、部署 -> 调试器

Click " Allow unsigned requests " checkbox and make it checked单击“ Allow unsigned requests ”复选框并选中它

This solved my issue.这解决了我的问题。


Or要么

Check your local environment.检查您的本地环境。 What I mean by saying check your local environment is usually more than one service is trying to use the same debugger port if we speak about the eg nodejs.我所说的检查本地环境的意思是,如果我们谈论 eg nodejs,通常不止一项服务试图使用相同的调试器端口。

You will get the following message if you try to run two services at the same time in the debug mode;如果您尝试在调试模式下同时运行两个服务,您将收到以下消息;

Starting inspector on 127.0.0.1:9229 failed: address already in use在 127.0.0.1:9229 上启动检查器失败:地址已被使用

Try to start the main service first that you try to debug.尝试首先启动您尝试调试的主要服务。

disabling js.debugger.use.node.options in the webstorm registry helped me在 webstorm 注册表中禁用js.debugger.use.node.options对我有帮助

https://youtrack.jetbrains.com/issue/WEB-47774#focus=Comments-27-4436526.0-0 https://youtrack.jetbrains.com/issue/WEB-47774#focus=Comments-27-4436526.0-0

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

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