3 V8 comes with an extensive debugger which is accessable out-of-process via a
4 simple [TCP protocol](http://code.google.com/p/v8/wiki/DebuggerProtocol).
5 Node has a built-in client for this debugger. To use this, start Node with the
6 `debug` argument; a prompt will appear:
8 % node debug myscript.js
11 At this point `myscript.js` is not yet running. To start the script, enter
12 the command `run`. If everything works okay, the output should look like
15 % node debug myscript.js
17 debugger listening on port 5858
20 Node's debugger client doesn't support the full range of commands, but
21 simple step and inspection is possible. By putting the statement `debugger;`
22 into the source code of your script, you will enable a breakpoint.
24 For example, suppose `myscript.js` looked like this:
28 setTimeout(function () {
34 Then once the debugger is run, it will break on line 4.
36 % ./node debug myscript.js
38 debugger listening on port 5858
41 break in #<an Object>._onTimeout(), myscript.js:4
45 break in #<an Object>._onTimeout(), myscript.js:5
54 break in #<an Object>._onTimeout() returning undefined, myscript.js:6
58 A debugging session is active. Quit anyway? (y or n) y
62 The `print` command allows you to evaluate variables. The `next` command steps
63 over to the next line. There are a few other commands available and more to
64 come type `help` to see others.
69 The V8 debugger can be enabled and accessed either by starting Node with
70 the `--debug` command-line flag or by signaling an existing Node process