Interactively Debug Node.js Applications with Chrome Dev Tools
Interactively Debugging Node.js Applications in Chrome Dev Tools
Debugging Node.js has always been a pain — using
console.log statements for debugging and checking variable values is time consuming and inefficient. The new debugging feature (experimental) is now available and supported in latest Node.js versions.
Here’s how to get up and running:
1. Download and install the current version of Node.js
nvm install node
2. Run you Application with --inspect flag
You can also break on the first statement of the script with --debug-brk
I am using the Tube2Gif application for demo.
3. Navigate to the generated URL in chrome
Locate the file you wish to inspect in sources and add breakpoints on the lines.
4. Execute that file by going to the appropriate URL
In my case, I'm searching for keyterms executes search.js
As you click the search button, the execution is paused in Chrome debugger and you can inspect all variable and stack from there.
If you'd like to discuss any of the above, need help, or would like to know where to go from here, let me know in the Codementor chat!