Debugging is an essential skill for any software engineer. In my opinion, a good debugging ability separates good engineers from the average. It also helps saving a lot of time while developing features or investigating issues. In this blog post, I will show you three techniques to debug NodeJS applications. Although these techniques are primarily for NodeJS developers, they can be applied to any programming languages or frameworks but with different debugging tools. If you prefer a video tutorial instead of reading, I have made a video here.
We will be working with a sample project that I prepared here. It is a very simple NodeJs server that calculates a count value and sends back 200 status code for requests on route ‘/’ as can be seen below. How can we inspect the count value?
I know, I know. We have all seen this old and uninteresting console.log statement before. But believe me, it is a powerful technique that is still used by most experienced engineers. In this exercise, to find out the value of count, a console.log simply does the job. Here are the pros and cons of this approach.
Pros:
#vscode #debugging #node #nodejs #chrome