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