How to debug remote node.js app using chrome devtools

為{幸葍}努か 提交于 2019-12-09 06:12:42

问题


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?


回答1:


Follow this instruction here Another good article here

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

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

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

chrome://inspect/#devices

You should see something like this:

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




回答2:


With Windows Client:

on remote server:

$ node --inspect server.js

On your local use Putty to create ssh tunel.

Click On Add botton:

On session tab Click to save!

And Click on Open.

You can check Tunnel is open with the following command:

netstat -a -n | grep 9221

On Your local open Chrome navigate to:

chrome://inspect/#devices



来源:https://stackoverflow.com/questions/50242557/how-to-debug-remote-node-js-app-using-chrome-devtools

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!