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:
$ 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:
- Open Chrome and type
chrome://inspectin the address bar. - Find
donations.jsunder Remote Target. - Click the inspect link below it.
- In the DevTools window that opens, go to the Sources panel.