Debug Node.js Applications Effectively
Let's learn to debug Node.js applications.
Debug applications
Many developers use console.log
to debug their Node.js applications. This technique is great for dumping a variable to the terminal so we can check its value or figure out what order our code is running in. However, it isn’t the best option.
Using console.log
to debug our code generally slows down the development process. This is because we have to repeatedly stop our application, insert a console.log
, and start our application again. Also, it complicates the debugging process since we’re trying to log out the values we’re debugging amidst the noise of other logging operations
Debug with an integrated development environment (IDE)
VSCode makes it easy to start a debugging environment for our Node.js application. Let’s take a look at an example.
- In our
script.js
file, add the following code:
Get hands-on with 1400+ tech skills courses.