Use Node Inspector (invoked with the
slc debug command) to debug Node applications. Node Inspector enables you to:
- Set breakpoints (and specify trigger conditions) in code, disable/enable all breakpoints.
- Step over, step in, step out, and resume code execution.
- Inspect scopes, variables, and object properties.
- Display the value of an expression in source code by hovering your mouse over it.
- Edit variables and object properties.
- Break on exceptions.
Make sure you've installed StrongLoop, which installs the
slc command-line tool.
Starting the debugger
Run your application in debug mode like this:
This command starts Node Inspector and opens the interface at http://localhost:8080/debug?port=5858 in your default browser.
If you don't want to run your application with the
slc debug command, then you must use the
node --debug-brk command to halt application execution on the first line. This enables you to set breakpoints, step through the code, and debug the application.
Debugging a running application
To enable debugging on an application that is already running:
Get the PID of the node process, for example:
Send the application the USR1 signal