How to debug remote node.js app using chrome devtools

后端 未结 3 1364
轻奢々
轻奢々 2020-12-31 12:56

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?

相关标签:
3条回答
  • 2020-12-31 13:18

    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

    0 讨论(0)
  • 2020-12-31 13:24

    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!

    0 讨论(0)
  • 2020-12-31 13:28

    You can follow the steps

    1)Run the application in remote
    2)Open application in chrome
    3)Open Developer Tools--->Sources
    4)Ctrl + p
    5)Open file you want to debug  there<filename.js>
    6)Place debug points in your now opened file.
    
    0 讨论(0)
提交回复
热议问题