Node.js · Junior · Question 69 of 75
How do you debug a Node.js app in Chrome DevTools or VS Code?
- ✓Correct answer: Start it with
node --inspect app.jsand attach the debugger - 2Add
debug: truetopackage.json - 3Run
npm debug
Explanation
--inspect opens the inspector protocol; --inspect-brk also pauses on the first line. In Chrome, open chrome://inspect. A debugger; statement sets a breakpoint in code.