# Use the Chrome DevTools to debug a Node.js app

> Learn how to debug a Node.js app with the Chrome DevTools by running node --inspect and opening about://inspect to attach the full debugger and profiler.

Author: Flavio Copes | Published: 2018-11-25 | Canonical: https://flaviocopes.com/node-debug-devtools/

With client-side code it's easy to start debugging some piece of code - just open the [Chrome DevTools](https://flaviocopes.com/browser-dev-tools/) on any page, and start writing client-side [JavaScript](https://flaviocopes.com/javascript/).

How can we do the same with [Node.js](https://flaviocopes.com/nodejs/) code, and debug Node modules with access to the filesystem and other Node.js capabilities? It's very simple, actually.

Open your [terminal](https://flaviocopes.com/macos-terminal/) and run

```bash
node --inspect
```

![Terminal showing debugger listening on ws://127.0.0.1:9229 after running node --inspect command](https://flaviocopes.com/images/node-debug-devtools/Screen_Shot_2018-11-02_at_17.52.35.png)

Then in Chrome type this URL: `about://inspect`.

![Chrome inspect page at about://inspect showing Open dedicated DevTools for Node link and remote target](https://flaviocopes.com/images/node-debug-devtools/Screen_Shot_2018-11-02_at_17.55.21.png)

Click the `Open dedicated DevTools for Node` link next to the Node target, and you'll have access to Node.js in the browser DevTools:

![Chrome DevTools console showing Node.js filesystem module with available methods like ReadStream and WriteStream](https://flaviocopes.com/images/node-debug-devtools/Screen_Shot_2018-11-02_at_17.56.12.png)

Make sure you click that, and not the `inspect` link down below, as it tool auto-reconnects to the Node.js instance when we restart it - pretty handy!

If the question is _why_ we want to do that, it's pretty simple: there's no better way to debug any JavaScript code than using the DevTools and their tools. We have access to the profiler, all the stack visualization information, the code navigation facilities, a very cool debugger and much more!
