If you don't know what the nodejs inspector is yet, its a very useful tool which allows a nodejs program to send console output to a google chrome dev console. And the google chrome inspector is super useful when dealing with json since it has the nested dropdown interface.

Basically to use it, all you have to do is go to the url chrome://inspect in chrome and click the "Open dedicated DevTools for Node" link. That should just open up a basic looking dev tools. Then to use the inspector, start node with the --inspect flag
node --inspect

Then anything you output to the console such as using console.log will get sent to the dev tools console.

I work on remote servers a lot and I wanted to find a way to use that on a remote node process. One way would be to open up ports 9229 and 9222 on the remote server and connect the DevTools console to that, but that seems like a huge security issue. So the method I came up with is to use an ssh tunnel. An ssh tunnel just connect a remote computer port locally. So if there is a process on port 8000 on the remote computer, an ssh tunnel can be used to bind that process to a local port so it seems as if the process is actually local.

Now, the chrome DevTools is configured by default to check ports 9229 and 9222 and when you first run node --inspect it should say something like
Debugger listening on ws://

which shows the port it is running on. No to get the chrome DevTools inspector hooked up, all we have to do is create an ssh tunnel to the remote computer connecting its port 9229 to our local 9229.

ssh -L 9229:localhost:9229 user@remote-ip -N -g

Assuming the node process is currently running on the remote computer, it should create the connection and data should start flowing through.