将WebStorm连接到远程node.js调试会话 [英] Connecting WebStorm to a remote node.js debugging session

查看:1604
本文介绍了将WebStorm连接到远程node.js调试会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Oracle VirtualBox中的Linux VM内运行Node.js应用程序。 VM上的端口 5858 转发到本地主机上的端口 5858

I am running a Node.js application within a Linux VM in Oracle VirtualBox. The port 5858 on the VM is forwarded to the port 5858 on the localhost.

我在主机操作系统(Windows 7)上运行WebStorm。在WebStorm中,单击运行>>编辑配置.... 然后单击添加按钮(加号),然后选择 Node.js远程调试。然后输入配置的名称,并将主机留为 127.0.0.1 ,端口为 5858 。我点击确定,并确保我的节点应用程序正在虚拟机上运行 - debug 标志。

I am running WebStorm on the host operating system (Windows 7). In WebStorm I click Run >> Edit Configurations.... I then click the add button (the plus sign) and select Node.js remote debug. I then enter the name of the configuration and leave the host as 127.0.0.1 and the port as 5858. I click OK, and ensure my node app is running on the VM with the --debug flag.

然后我点击WebStorm工具栏中的错误图标,调试器出现在WebStorm IDE的底部。

I then click the bug icon in the WebStorm toolbar and the debugger appears at the bottom of the WebStorm IDE.

我可以确认连接是否成功完成?断点不起作用,WebStorm中的控制台保持为空(信息发送到Linux VM上的控制台)。任何人都可以提出要使远程调试会话工作有什么工作?

How can I confirm that the connection is made successfully? Breakpoints do not work and the console in WebStorm remains empty (while information is sent to the console on the Linux VM). Can anyone suggest what remains to be done to get the remote debugging session working?

推荐答案

而不是仅仅

$ vagrant ssh

尝试

$ vagrant ssh -- -L 5858:127.0.0.1:5858

我也删除了 config.vm.network:forwarding_port,guest:5858,host:5858 从我的 Vagrantfile ,并执行了一个 $ vagrant reload

I also removed the line config.vm.network :forwarded_port, guest: 5858, host: 5858 from my Vagrantfile and did a $ vagrant reload.

在您的流氓框中运行

$ node --debug-brk path/to/file.js

设置Node.js远程调试运行/调试配置,默认值很好(主机127.0.0.1和端口5858)。

Set up a Node.js Remote Debug Run/Debug configuration, defaults are fine (host 127.0.0.1 and port 5858).

从HOST机器运行以下操作,而不是您的流氓框。

Run the following from your HOST machine, not your vagrant box.

$ telnet 127.0.0.1 5858

您应该得到如

Type: connect
V8-Version: 3.14.5.9
Protocol-Version: 1
Embedding-Host: node v0.10.28
Content-Length: 0

如果您没有向前转发出错误的话。您可以在主机端尝试不同的端口,并将以前从端口5858设置的网络风暴运行/调试配置更新到新端口。

If you don't then something wrong with the port forward. You could try a different port on the host end and update your webstorm Run/Debug configuration that was previously set up from port 5858 to the new port.

现在运行NodeJS调试配置。它应该立即拿起文件,你可以调试它。

Now run the NodeJS debug configuration. It should immediately pick up the file and you'll be able to debug it.

我基于PHPStorm的步骤,但它应该是一样的。只要您安装了NodeJS插件,我假设它将在所有基于IntelliJ的IDE上工作。

I based my steps off of PHPStorm, but it should be the same. I'm assuming it'll work on all IntelliJ-based IDEs as long as you have the NodeJS plugin installed.

这篇关于将WebStorm连接到远程node.js调试会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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