Like every major programming platform, node.js comes with a built-in debugger that can be executed by running
node debug app.js.
The application will start paused and you'll need to use the debugger commands to run the app. By pressing
c the application will continue it's execution.
The debugger is a client application that connects to the port
5858 that the node interpreter opens when in debug mode.
debugger;statement on your code to create auto breakpoints, pausing the application.
If you have a node.js app already running run
kill -SIGUSR1 $PIDto enable debug mode on it.
I want to use an IDE!
If you take the IDE away from a java developer they feel really insecure.
Once you have your node.js app running in debug mode you can use free node.js debugger clients like
iron-node, or use proprietary IDE like
JetBrains WebStorm, or
Visual Studio Code.
I personally like free and open source debugging tools, so I'll describe how debug a node.js application using node-inspector.
node debug app.js
cto continue the application execution
node-inspectorand open http://127.0.0.1:8080/debug?port=5858 to debug the app using a chrome developer tools alike debugger.