Diagnosing issues with Chrome DevTools
Node.js exposes a debugging utility via the --inspect process flag, which enables us to debug and profile our Node.js processes using the Chrome DevTools interface. The integration is enabled via the Chrome DevTools Protocol. The existence of this protocol means that tools can be written to integrate with Chrome DevTools.
Important Note
node --debug and node --debug-brk are legacy Node.js process flags that have been deprecated since Node.js v6.3.0. node --inspect and node --inspect-brk are the modern equivalents that should be used in place of these legacy flags.
In the recipe, we will learn how to use Chrome DevTools to diagnose issues within a web application.
Getting ready
In this recipe, we will debug a small web server. Let's prepare this before we start the recipe:
- First, let's set up a directory and the files required for this recipe:
$ mkdir debugging-with-chrome $ cd debugging-with-chrome $ npm init ...