Debugging in Chrome DevTools and VS Code

In the last lesson, node inspect stopped at your debugger; statement, and exec showed amountText. The terminal debugger can do more, but everything goes through typed commands. For November’s refund on row 6, you’d rather click a line and read every variable at a glance.

In this lesson, you’ll pause the import in Chrome DevTools and VS Code, stop only at the row you want, and catch it as it throws. First, delete the debugger; line from parseRow(), since breakpoints you set by clicking don’t need it.

Start the Import Paused in Chrome DevTools

For a graphical debugger, start Node with the --inspect-brk option, which pauses execution before the first line until a debugger connects. In a terminal in ~/donations, run:

Language: Shell
$ node --inspect-brk donations.js november.csv
Debugger listening on ws://127.0.0.1:9229/4d9e3833-3657-4ec9-bab5-0f96b29e8d99
For help, see: https://nodejs.org/learn/getting-started/debugging

The ID at the end is random. Watch out for where the option goes: as -m pdb goes before donations.py in Python, Node’s options sit between node and the filename, because anything after donations.js goes to the script, which would report no export at --inspect-brk.

While Node waits, attach Chrome:

  1. Open Chrome and type chrome://inspect in the address bar.
  2. Find donations.js under Remote Target.
  3. Click the inspect link below it.
  4. In the DevTools window that opens, go to the Sources panel.

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Become a Member to join the conversation.