/

Debugging a Node.js app using Chrome DevTools

Debugging a Node.js app using Chrome DevTools

When it comes to programming, it’s often necessary to test and experiment with code quickly. While it’s easy to debug client-side code using Chrome DevTools, debugging Node.js code with access to the filesystem and other Node.js capabilities might seem a bit challenging. However, it’s actually quite simple.

To debug a Node.js app using Chrome DevTools, follow these steps:

  1. Open your terminal and run the following command:

    1
    node --inspect

    This will start the Node.js inspector.

  2. In Chrome, type about://inspect in the URL bar.

  3. Click on the Open dedicated DevTools for Node link next to the Node target.

    DevTools screenshot

    Note: Make sure to click this link and not the inspect link below, as the dedicated DevTools auto-reconnects to the Node.js instance when it is restarted.

Debugging Node.js code using Chrome DevTools provides numerous benefits. It gives you access to the profiler, stack visualization information, code navigation facilities, a powerful debugger, and much more. There isn’t a better way to debug JavaScript code than by using the DevTools and their tools.

tags: [“Node.js”, “debugging”, “Chrome DevTools”]