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')
For debugger's uses we need to configure one port into an extension of chrome web browser, copy on your web address:
chrome://inspect/
Click on configure and add the localhost:9229
address:
We are going to use the command below to start the debugger:
node --inspect index.js
After run the previous command --inspect, in the next step we need to click on inspect
button, below the remote target.
And will be open the DevTools:
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)
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.