How do you debug a Node.js server running with Chrome/WebKit as the remote debugger? How do you debug a Node.js server running with Chrome/WebKit as the remote debugger? node.js node.js

How do you debug a Node.js server running with Chrome/WebKit as the remote debugger?


The node-inspector / --debug are now replaced by inspectorSee update below

#now deprecated / see below for update#install node-inspectornpm install -g node-inspector#start node-inspector, listen on port 8080 (default)node-inspector --web-port=8080#in another terminal session/window:#while node-inspector is running, start your project in debug mode node --debug myproject.js

Now you can browse to http://your_server:8080 for a full debug session of myproject.js

If your remote server is not accessible on the remote port because of firewalls or other reasons, you could create an ssh-tunnel to it from port 8080 on your local machine to 'localhost:8080' on the remote server:

ssh -L 8080:localhost:8080 username@remoteserver -N

and keep this running while you use http://localhost:8080 on your local machine to debug your remote nodejs session


Update august 2017

Start node in inspect mode:

node --inspect=0.0.0.0:9229 myproject.js

or if you want the debugger to break at the first line of myproject.js:

node --inspect-brk=0.0.0.0:9229 myproject.js

Then open the following URL in your chrome browser:

chrome://inspect

Click the 'Configure...' button and add the following target:

ip-or-name-of-server-running-node:9229

After you click the 'Done' button, you should see myproject.js under your remote targets. Click the inspect link to start debugging. Unfortunately, the inspect link does not work on Chrome 58 for Ubuntu. It works fine on Chrome 60 for Windows.


Use node-inspector to remotely debug your node application from Chrome that you've started with the --debug option as you've shown.


Recent versions of Node (> v6.3.0) and Chrome now allow you to use the Chrome Developer Tools to debug a Node.JS process without having to install anything else. Just pass --inspect to node:

$ node --inspect script.jsDebugger listening on port 9229.Warning: This is an experimental feature and could change at any time.To start debugging, open the following URL in Chrome:    chrome-devtools://SOME-URL-HERE

Just open that URL in Chrome, and you're good to go.

If you need to pause your script immediately after Node starts, you can also pass --debug-brk in the same command.