Appendix B. Debugging Node

 

During development, and especially while learning a new language or framework, debugging tools and techniques can be helpful. In this appendix, you’ll learn a number of ways to figure out exactly what’s going on with your Node application code.

B.1. Analyzing code with JSHint

Syntax- and scope-related errors are a common pitfall of development. The first line of defense, when attempting to determine the root of an application problem, is to look at the code. If you look at the source code, however, and don’t immediately see a problem, another thing worth doing is running a utility to check your source code for problems.

JSHint is one such utility. It can alert you to show-stopping errors, such as functions called in code that aren’t defined anywhere, as well as to stylistic concerns, such as not heeding the JavaScript convention of capitalizing class constructors. Even if you never run JSHint, reading over the types of errors it looks for will alert you to possible coding pitfalls.

JSHint is a project based on JSLint, a JavaScript source code analysis tool that has been around for a decade. JSLint, however, is not very configurable, and that’s where JSHint comes in.

B.2. Outputting debugging information

B.3. Node’s built-in debugger

B.4. Node Inspector