Built-in Node.js inspector
suggest changeNode.js includes the V8 inspector. Start a script and pause before its first statement with:
node --inspect-brk filename.js
Use --inspect when the script should start immediately. Node.js prints a WebSocket inspector URL. Open chrome://inspect in Chrome or attach with a compatible editor.
The debugger statement creates a source breakpoint:
'use strict';
function addTwoNumbers(a, b) {
debugger;
return a + b;
}
const result = addTwoNumbers(5, 9);
console.log(result);
14
Do not expose the inspector port to untrusted networks. An attached debugger can execute code in the process.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents