Skip to content

Commit 32ddb66

Browse files
Jan Kremsaddaleax
Jan Krems
authored andcommitted
doc: match debugger output & instructions to master behavior
PR-URL: #13885 Reviewed-By: Colin Ihrig <[email protected]>
1 parent b97e140 commit 32ddb66

File tree

1 file changed

+32
-34
lines changed

1 file changed

+32
-34
lines changed

doc/api/debugger.md

+32-34
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,18 @@
66

77
Node.js includes an out-of-process debugging utility accessible via a
88
[TCP-based protocol][] and built-in debugging client. To use it, start Node.js
9-
with the `debug` argument followed by the path to the script to debug; a prompt
9+
with the `inspect` argument followed by the path to the script to debug; a prompt
1010
will be displayed indicating successful launch of the debugger:
1111

1212
```txt
13-
$ node debug myscript.js
14-
< Debugger listening on 127.0.0.1:5858
15-
connecting to 127.0.0.1:5858 ... ok
16-
break in /home/indutny/Code/git/indutny/myscript.js:1
17-
> 1 global.x = 5;
13+
$ node inspect myscript.js
14+
< Debugger listening on ws://127.0.0.1:9229/80e7a814-7cd3-49fb-921a-2e02228cd5ba
15+
< For help see https://nodejs.org/en/docs/inspector
16+
< Debugger attached.
17+
Break on start in myscript.js:1
18+
> 1 (function (exports, require, module, __filename, __dirname) { global.x = 5;
1819
2 setTimeout(() => {
19-
3 debugger;
20+
3 console.log('world');
2021
debug>
2122
```
2223

@@ -40,23 +41,24 @@ console.log('hello');
4041
Once the debugger is run, a breakpoint will occur at line 3:
4142

4243
```txt
43-
$ node debug myscript.js
44-
< Debugger listening on 127.0.0.1:5858
45-
connecting to 127.0.0.1:5858 ... ok
46-
break in /home/indutny/Code/git/indutny/myscript.js:1
47-
> 1 global.x = 5;
44+
$ node inspect myscript.js
45+
< Debugger listening on ws://127.0.0.1:9229/80e7a814-7cd3-49fb-921a-2e02228cd5ba
46+
< For help see https://nodejs.org/en/docs/inspector
47+
< Debugger attached.
48+
Break on start in myscript.js:1
49+
> 1 (function (exports, require, module, __filename, __dirname) { global.x = 5;
4850
2 setTimeout(() => {
4951
3 debugger;
5052
debug> cont
5153
< hello
52-
break in /home/indutny/Code/git/indutny/myscript.js:3
53-
1 global.x = 5;
54+
break in myscript.js:3
55+
1 (function (exports, require, module, __filename, __dirname) { global.x = 5;
5456
2 setTimeout(() => {
5557
> 3 debugger;
5658
4 console.log('world');
5759
5 }, 1000);
5860
debug> next
59-
break in /home/indutny/Code/git/indutny/myscript.js:4
61+
break in myscript.js:4
6062
2 setTimeout(() => {
6163
3 debugger;
6264
> 4 console.log('world');
@@ -69,14 +71,14 @@ Press Ctrl + C to leave debug repl
6971
> 2+2
7072
4
7173
debug> next
72-
break in /home/indutny/Code/git/indutny/myscript.js:5
7374
< world
75+
break in myscript.js:5
7476
3 debugger;
7577
4 console.log('world');
7678
> 5 }, 1000);
7779
6 console.log('hello');
7880
7
79-
debug> quit
81+
debug> .exit
8082
```
8183

8284
The `repl` command allows code to be evaluated remotely. The `next` command
@@ -121,27 +123,23 @@ It is also possible to set a breakpoint in a file (module) that
121123
is not loaded yet:
122124

123125
```txt
124-
$ node debug test/fixtures/break-in-module/main.js
125-
< Debugger listening on 127.0.0.1:5858
126-
connecting to 127.0.0.1:5858 ... ok
127-
break in test/fixtures/break-in-module/main.js:1
128-
> 1 const mod = require('./mod.js');
126+
$ node inspect test/fixtures/break-in-module/main.js
127+
< Debugger listening on ws://127.0.0.1:9229/4e3db158-9791-4274-8909-914f7facf3bd
128+
< For help see https://nodejs.org/en/docs/inspector
129+
< Debugger attached.
130+
Break on start in test/fixtures/break-in-module/main.js:1
131+
> 1 (function (exports, require, module, __filename, __dirname) { const mod = require('./mod.js');
129132
2 mod.hello();
130133
3 mod.hello();
131-
debug> setBreakpoint('mod.js', 2)
134+
debug> setBreakpoint('mod.js', 22)
132135
Warning: script 'mod.js' was not loaded yet.
133-
> 1 const mod = require('./mod.js');
134-
2 mod.hello();
135-
3 mod.hello();
136-
4 debugger;
137-
5
138-
6 });
139136
debug> c
140-
break in test/fixtures/break-in-module/mod.js:2
141-
1 exports.hello = function() {
142-
> 2 return 'hello from module';
143-
3 };
144-
4
137+
break in test/fixtures/break-in-module/mod.js:22
138+
20 // USE OR OTHER DEALINGS IN THE SOFTWARE.
139+
21
140+
>22 exports.hello = function() {
141+
23 return 'hello from module';
142+
24 };
145143
debug>
146144
```
147145

0 commit comments

Comments
 (0)