DEV Community

Cover image for You don't need VSCode to debug your Node.js app [Google Chrome V8 inspect and debugger breakpoint]
Luiz Calaça
Luiz Calaça

Posted on

You don't need VSCode to debug your Node.js app [Google Chrome V8 inspect and debugger breakpoint]

Hi, Devs!

When we look at Node.js documentation there's a interesting option do debug our code and is inspector context


Let'a create a piece of code and let's use a debugger word that means a breakpoint for our debug process.

//index.js

console.log('hello')
setTimeout(() => {
    debugger
    console.log('After debugger breakpoint')
}, 8000)
debugger
console.log('Finished')
Enter fullscreen mode Exit fullscreen mode

For debugger's uses we need to configure one port into an extension of chrome web browser, copy on your web address:

chrome://inspect/
Enter fullscreen mode Exit fullscreen mode

Click on configure and add the localhost:9229 address:

Node.js Chrome V8 Inspector Debugger

We are going to use the command below to start the debugger:

node --inspect index.js
Enter fullscreen mode Exit fullscreen mode

After run the previous command --inspect, in the next step we need to click on inspect button, below the remote target.

Debugger V8 Javascript

And will be open the DevTools:

DevTools Debugger Javascript

And you could use the next button on the right of the image above where is writing Debugger paused

You could add some expression on Watch to verify some value and into Scope verify the returns.

Contacts
Email: luizcalaca@gmail.com
Instagram: https://www.instagram.com/luizcalaca
Linkedin: https://www.linkedin.com/in/luizcalaca/
Twitter: https://twitter.com/luizcalaca

Top comments (1)

Collapse
 
luizcalaca profile image
Luiz Calaça

It depends, maybe you could use because you already are debugging on DevTools some React.js app. Maybe in other context some developers couldn't use VsCode or other IDE and just a simple editor. That's just one possible option if you'd like to use and that's interesting because we have a great profiler using with --inspect on DevTools.