0% found this document useful (0 votes)
42 views

3 Ways To Debug Node - JS: by Gergely Nemeth at Risingstack

This document provides 3 methods for debugging Node.js applications: 1. The debug module allows setting the DEBUG environment variable to print logs for specific modules like "express". 2. Node.js includes a built-in debugger that can be started with "node debug app.js" and provides commands like "c" to continue and "n" to step to the next line. 3. The Chrome debugger can be used by installing node-inspector and running "node-debug index.js --debug-brk" to pause execution and debug in Chrome Dev tools.

Uploaded by

htdvul
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views

3 Ways To Debug Node - JS: by Gergely Nemeth at Risingstack

This document provides 3 methods for debugging Node.js applications: 1. The debug module allows setting the DEBUG environment variable to print logs for specific modules like "express". 2. Node.js includes a built-in debugger that can be started with "node debug app.js" and provides commands like "c" to continue and "n" to step to the next line. 3. The Chrome debugger can be used by installing node-inspector and running "node-debug index.js --debug-brk" to pause execution and debug in Chrome Dev tools.

Uploaded by

htdvul
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

by Gergely Nemeth @

RisingStack

3 Ways to
Debug
Node.js

Use this Cheat-Sheet to


debug Node.js easily
Method 1: The debug module
▢ To check whether a module is using the debug module, take a look at the
package.json file's dependency section.

▢ Set the DEBUG environment variable when starting your app. You can
also use the * character to wildcard names.

▢ The following line will print all the express related logs to the standard
output > DEBUG=express* node app.js

Method 2: The Built-in Node.js Debugger


▢ Node.js includes a full-featured built-in debugging client. To start the
built-in debugger you have to start your application this way: "node
debug app.js"

▢ To navigate this interface, use the following commands:


c => continue with code execution
n => execute this line and go to next line
s => step into this function
o => finish function execution and step out
repl => allows code to be evaluated remotely

Method 3: The Chrome Debugger


▢ Install node-inspector first: "npm install -g node-inspector"

▢ Start debugging your app by starting this way: "node-debug index.js --


debug-brk " (the --debug-brk pauses the execution on the first line)

▢ It will open up the Chrome Dev tools and you can start to debug your app
JOIN FOR
MORE FREE
RESOURCES

Watch the 9-minute screencast to get


the most out of this cheat sheet

JOIN NOW

You might also like