So I’ve come across a strange “wall” with my Node.js/MEAN stack journey. This wall is debugging.
I come from a C#/.NET background where when using Visual Studio Community 2015, I can simply set a breakpoint in the code, such as on a controller which takes input from a route (Equivalent of app.get or app.post in Express), and then the debugger will listen for when I access that route via a web browser, and then it will allow me to step through the code as soon as I access the route via the web browser, allowing me to see all of the passed variables and outcome of the code.
However, I am having a beast of a time in getting this to work with Node.js. In addition, I have a community/help group of MEAN developers in my area through the local FCC meetup, all who seem to be completely oblivious to debugging. So this raises several questions:
Is using the debugger “not a thing” yet in Node? If so, why not and what are alternative ways to debug my node code?
If node code can be easily debugged, how?
Debugging is one of the absolute most core components of software engineering and it is how I solve 99% of my software issues. Without it, I feel lost at times and at a severe handicap.
What I have tried:
I usually use Visual Studio Code with Node.js which is a fantastic editor. I does have a debug feature, but it behaves significantly differently than the Visual Studio C#/ASP.NET debugging that I am used to.
For example, in ASP.NET using Visual Studio, if I am having an issue with controller logic, I set a breakpoint on the controller’s method and then hit F5 for Debug. I then launch a browser and when I hit the controller’s endpoint/route, the code execution stops at the breakpoint and allows me to step through code.
However, this doesn’t appear to be the case with the Visual Studio Code/Node debugger. In Node, when I set a breakpoint and then run the program, it does stop at the breakpoint, but it does it before I even browse to the controller, which makes it fundamentally useless because without my browser passing any data to the controller, the debugging session is faulty and of no help. Also, debugging seems to be strangely absent even from paid tutorials I’ve purchased online for Node.
Anyone have any advice for me? I’m finding this quite odd. I’ve heard “Well, JS is an interpreted language and C# is compiled” which is true, but Im not buying that as a valid excuse to have such a complicated/useless debugging system because clearly the debugger has the capability of proper functionality as indicated by the fact that it indeed does allow full stepthrough and watches.
Last but not least. I am aware of alternatives such as console.log and “manual” debugging, however, I am speaking of the actual debugger here. Thank you.