如何使用Chrome开发者工具调试远程Node.js应用 [英] How to debug remote node.js app using chrome devtools

查看:106
本文介绍了如何使用Chrome开发者工具调试远程Node.js应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的控制台node.js应用程序,该应用程序正在远程服务器上运行.我想使用Chrome DevTools对其进行远程调试.我该怎么办?

I have a simple console node.js app that is running on a remote server. I would like to debug it remotely using the Chrome DevTools. How can I do that?

推荐答案

遵循此说明此处

Follow this instruction here Another good article here

假设您要在远程计算机上运行Node,并且希望对其进行调试.在该机器上,应该使用检查器仅侦听localhost(默认值)的方式启动节点进程.

Let's say you are running Node on remote machine, remote.example.com, that you want to be able to debug. On that machine, you should start the node process with the inspector listening only to localhost (the default).

$ node --inspect server.js

现在,在您要从其启动调试客户端连接的本地计算机上,可以设置ssh隧道:

Now, on your local machine from where you want to initiate a debug client connection, you can setup an ssh tunnel:

$ ssh -L 9221:localhost:9229 user@remote.example.com

然后在Chrome浏览器中的本地计算机上转到地址:

Then on your local machine in the Chrome browser go to this address:

chrome://inspect/#devices

chrome://inspect/#devices

您应该会看到类似这样的内容:

You should see something like this:

点击inspect后,您应该会看到熟悉的Chrome开发者工具窗口.祝你好运!

Once you click inspect you should see the familiar Chrome developers tool window. Good luck!

这篇关于如何使用Chrome开发者工具调试远程Node.js应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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