DEV Community

Discussion on: Stop only using console.log and use the built-in node debugger

Collapse
 
leob profile image
leob • Edited

You know what, with PHP I'm ALWAYS using the debugger, with JS (mostly front end, that is) I keep reverting to console.log ... why? because JS is async and debugging through async code is a pain in the rear.

Also, as soon as JS is being transpiled (Babel and Webpack and so on) it becomes a pain unless you've "mastered" the art of setting up code maps (I'm not even using the proper word I think, that's how far detached I am from this whole thing).

I can't be bothered with that debugger, "console.log" just gets me the answers that I need in a faster and easier way.

Just give me transparent JS debugging without the whole async and transpilation crap, the moment I don't need a degree in theoretical quantum mechanics in order to be smart enough to use the JS debugger then I'll use it.

Collapse
 
nyxtom profile image
Tom Holloway 🏕

Indeed, another common method I've used for years is just add a number of debug statements and control the level of debug logs with DEBUG=pattern*. Helps for when you need a quick overview of what's happening over time without wanting to step into things. This post is mainly referencing the uncommonly used chrome debugger for nodejs backend code that is available.

Collapse
 
leob profile image
leob

Good points, DEBUG=pattern* has occasionally also worked for me, or putting breakpoints at specific places rather than trying to step into things.