If you have your Node running
node --debug server.js
This gives me a port number xxxx, should I use this port number when starting Chrome?
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.js
Debugger 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.