How to remote debug Node JS with PHPStorm?

后端 未结 2 1777
鱼传尺愫
鱼传尺愫 2021-02-06 01:38

I have a windows box and a VM running CentOS. Does anyone happen to know how I can debug a node CLI script (which doesn\'t open a port) using PHPStorm? The \"edit configuration\

2条回答
  •  孤街浪徒
    2021-02-06 02:24

    Make sure you have the nodejs plugin installed.

    If your server has the balancer package available (my EC2 box didn't), you can use this tutorial to forward the port with balancer.

    yum install balance -yt
    balance -df 8585 127.0.0.1.5858
    

    Many report success with an iptables redirect from eth0 to lo (didn't work for me) like this:

    iptables -t nat -A PREROUTING -p tcp -m tcp -i eth0 --dport 5858 -j DNAT --to 127.0.0.1:5858
    

    There is also a simple node script described in this eclipse debugging tut (near the bottom), that will tunnel your local debug to a remote host.

    But once I was that far down the path, I didn't see the point as I'm familiar with SSH. So ultimately, I went with an SSH tunnel and set up PHPStorm to debug localhost. SSH Tunnel using putty

    PHPStorm configuration

提交回复
热议问题