If you have your Node running
如果您的节点正在运行
node --debug server.js
This gives me a port number xxxx, should I use this port number when starting Chrome?
这给了我一个端口号xxxx,我应该在启动Chrome时使用这个端口号吗?
Do you remote debug into it from Google\ Chrome --remote-debugging-port=xxxx
?
你是否通过Google \ Chrome远程调试它?--remote-debugging-port = xxxx?
Or is the 9222 a magic port, as it is mentioned all over.
或者9222是一个神奇的端口,因为它已被提及。
Am I on the right track, trying to start Chrome with --remote-debugger
into the Node.js server.js
我是否在正确的轨道上,尝试使用--remote-debugger启动Chrome到Node.js server.js
4 个解决方案
#1
13
The node-inspector / --debug are now replaced by inspector See update below
现在,节点检查器/ --debug已由检查器替换。请参阅下面的更新
#now deprecated / see below for update
#install node-inspector
npm install -g node-inspector
#start node-inspector, listen on port 8080 (default)
node-inspector --web-port=8080
#in another terminal session/window:
#while node-inspector is running, start your project in debug mode
node --debug myproject.js
Now you can browse to http://your_server:8080 for a full debug session of myproject.js
现在,您可以浏览http:// your_server:8080以获取myproject.js的完整调试会话
If your remote server is not accessible on the remote port because of firewalls or other reasons, you could create an ssh-tunnel to it from port 8080 on your local machine to 'localhost:8080' on the remote server:
如果由于防火墙或其他原因无法在远程端口*问远程服务器,则可以从本地计算机上的端口8080到远程服务器上的“localhost:8080”创建一个ssh-tunnel:
ssh -L 8080:localhost:8080 username@remoteserver -N
and keep this running while you use http://localhost:8080 on your local machine to debug your remote nodejs session
并在本地计算机上使用http:// localhost:8080时保持此运行以调试远程nodejs会话
Update august 2017
2017年8月更新
Start node in inspect mode:
在检查模式下启动节点:
node --inspect=0.0.0.0:9229 myproject.js
or if you want the debugger to break at the first line of myproject.js:
或者如果您希望调试器在myproject.js的第一行中断:
node --inspect-brk=0.0.0.0:9229 myproject.js
Then open the following URL in your chrome browser:
然后在Chrome浏览器中打开以下网址:
chrome://inspect
Click the 'Configure...' button and add the following target:
单击“配置...”按钮并添加以下目标:
ip-or-name-of-server-running-node:9229
After you click the 'Done' button, you should see myproject.js under your remote targets. Click the inspect link to start debugging. Unfortunately, the inspect link does not work on Chrome 58 for Ubuntu. It works fine on Chrome 60 for Windows.
单击“完成”按钮后,您应该在远程目标下看到myproject.js。单击inspect链接开始调试。不幸的是,检查链接在Chrome 58 for Ubuntu上不起作用。它适用于Chrome 60 for Windows。
#2
9
Use node-inspector
to remotely debug your node application from Chrome that you've started with the --debug
option as you've shown.
如您所示,使用node-inspector从您使用--debug选项启动的Chrome远程调试节点应用程序。
#3
4
Recent versions of Node (> v6.3.0) and Chrome now allow you to use the Chrome Developer Tools to debug a Node.JS process without having to install anything else. Just pass --inspect
to node
:
最新版本的Node(> v6.3.0)和Chrome现在允许您使用Chrome开发者工具调试Node.JS流程,而无需安装任何其他内容。只需传递--inspect到节点:
$ node --inspect script.js
Debugger listening on port 9229.
Warning: This is an experimental feature and could change at any time.
To start debugging, open the following URL in Chrome:
chrome-devtools://SOME-URL-HERE
Just open that URL in Chrome, and you're good to go.
只需在Chrome中打开该网址,就可以了。
If you need to pause your script immediately after Node starts, you can also pass --debug-brk
in the same command.
如果您需要在Node启动后立即暂停脚本,您也可以在同一命令中传递--debug-brk。
#4
0
-
using $ vagrant ssh -- -L 5858:127.0.0.1:5858
使用$ vagrant ssh - -L 5858:127.0.0.1:5858
to ssh connect to VM. also this comment would start a proxy server on port 5858;
-
you could test using telnet 127.0.0.1 5858 to see if local proxy server started or not.
您可以使用telnet 127.0.0.1 5858进行测试,以查看本地代理服务器是否已启动。
-
In VM, you can start node with command
在VM中,您可以使用命令启动节点
-
$ node --debug-brk app.js
$ node --debug-brk app.js
- set up debug configuration in web storm.
- 在Web风暴中设置调试配置。
- when you start debug in web storm, node.js server in VM will start in a few seconds.
- 当您在Web风暴中启动调试时,VM中的node.js服务器将在几秒钟内启动。
PS: there is no need to touch the vagrant file. Reference: Connecting WebStorm to a remote node.js debugging session.
PS:没有必要触摸流浪文件。参考:将WebStorm连接到远程node.js调试会话。
#1
13
The node-inspector / --debug are now replaced by inspector See update below
现在,节点检查器/ --debug已由检查器替换。请参阅下面的更新
#now deprecated / see below for update
#install node-inspector
npm install -g node-inspector
#start node-inspector, listen on port 8080 (default)
node-inspector --web-port=8080
#in another terminal session/window:
#while node-inspector is running, start your project in debug mode
node --debug myproject.js
Now you can browse to http://your_server:8080 for a full debug session of myproject.js
现在,您可以浏览http:// your_server:8080以获取myproject.js的完整调试会话
If your remote server is not accessible on the remote port because of firewalls or other reasons, you could create an ssh-tunnel to it from port 8080 on your local machine to 'localhost:8080' on the remote server:
如果由于防火墙或其他原因无法在远程端口*问远程服务器,则可以从本地计算机上的端口8080到远程服务器上的“localhost:8080”创建一个ssh-tunnel:
ssh -L 8080:localhost:8080 username@remoteserver -N
and keep this running while you use http://localhost:8080 on your local machine to debug your remote nodejs session
并在本地计算机上使用http:// localhost:8080时保持此运行以调试远程nodejs会话
Update august 2017
2017年8月更新
Start node in inspect mode:
在检查模式下启动节点:
node --inspect=0.0.0.0:9229 myproject.js
or if you want the debugger to break at the first line of myproject.js:
或者如果您希望调试器在myproject.js的第一行中断:
node --inspect-brk=0.0.0.0:9229 myproject.js
Then open the following URL in your chrome browser:
然后在Chrome浏览器中打开以下网址:
chrome://inspect
Click the 'Configure...' button and add the following target:
单击“配置...”按钮并添加以下目标:
ip-or-name-of-server-running-node:9229
After you click the 'Done' button, you should see myproject.js under your remote targets. Click the inspect link to start debugging. Unfortunately, the inspect link does not work on Chrome 58 for Ubuntu. It works fine on Chrome 60 for Windows.
单击“完成”按钮后,您应该在远程目标下看到myproject.js。单击inspect链接开始调试。不幸的是,检查链接在Chrome 58 for Ubuntu上不起作用。它适用于Chrome 60 for Windows。
#2
9
Use node-inspector
to remotely debug your node application from Chrome that you've started with the --debug
option as you've shown.
如您所示,使用node-inspector从您使用--debug选项启动的Chrome远程调试节点应用程序。
#3
4
Recent versions of Node (> v6.3.0) and Chrome now allow you to use the Chrome Developer Tools to debug a Node.JS process without having to install anything else. Just pass --inspect
to node
:
最新版本的Node(> v6.3.0)和Chrome现在允许您使用Chrome开发者工具调试Node.JS流程,而无需安装任何其他内容。只需传递--inspect到节点:
$ node --inspect script.js
Debugger listening on port 9229.
Warning: This is an experimental feature and could change at any time.
To start debugging, open the following URL in Chrome:
chrome-devtools://SOME-URL-HERE
Just open that URL in Chrome, and you're good to go.
只需在Chrome中打开该网址,就可以了。
If you need to pause your script immediately after Node starts, you can also pass --debug-brk
in the same command.
如果您需要在Node启动后立即暂停脚本,您也可以在同一命令中传递--debug-brk。
#4
0
-
using $ vagrant ssh -- -L 5858:127.0.0.1:5858
使用$ vagrant ssh - -L 5858:127.0.0.1:5858
to ssh connect to VM. also this comment would start a proxy server on port 5858;
-
you could test using telnet 127.0.0.1 5858 to see if local proxy server started or not.
您可以使用telnet 127.0.0.1 5858进行测试,以查看本地代理服务器是否已启动。
-
In VM, you can start node with command
在VM中,您可以使用命令启动节点
-
$ node --debug-brk app.js
$ node --debug-brk app.js
- set up debug configuration in web storm.
- 在Web风暴中设置调试配置。
- when you start debug in web storm, node.js server in VM will start in a few seconds.
- 当您在Web风暴中启动调试时,VM中的node.js服务器将在几秒钟内启动。
PS: there is no need to touch the vagrant file. Reference: Connecting WebStorm to a remote node.js debugging session.
PS:没有必要触摸流浪文件。参考:将WebStorm连接到远程node.js调试会话。