@@ -11,10 +11,10 @@ will be displayed indicating successful launch of the debugger:
11
11
12
12
``` txt
13
13
$ node debug myscript.js
14
- < debugger listening on port 5858
15
- connecting... ok
14
+ < Debugger listening on 127.0.0.1: 5858
15
+ connecting to 127.0.0.1:5858 ... ok
16
16
break in /home/indutny/Code/git/indutny/myscript.js:1
17
- 1 x = 5;
17
+ > 1 global. x = 5;
18
18
2 setTimeout(() => {
19
19
3 debugger;
20
20
debug>
@@ -28,37 +28,37 @@ enable a breakpoint at that position in the code:
28
28
29
29
``` js
30
30
// myscript.js
31
- x = 5 ;
31
+ global . x = 5 ;
32
32
setTimeout (() => {
33
33
debugger ;
34
34
console .log (' world' );
35
35
}, 1000 );
36
36
console .log (' hello' );
37
37
```
38
38
39
- Once the debugger is run, a breakpoint will occur at line 4 :
39
+ Once the debugger is run, a breakpoint will occur at line 3 :
40
40
41
41
``` txt
42
42
$ node debug myscript.js
43
- < debugger listening on port 5858
44
- connecting... ok
43
+ < Debugger listening on 127.0.0.1: 5858
44
+ connecting to 127.0.0.1:5858 ... ok
45
45
break in /home/indutny/Code/git/indutny/myscript.js:1
46
- 1 x = 5;
46
+ > 1 global. x = 5;
47
47
2 setTimeout(() => {
48
48
3 debugger;
49
49
debug> cont
50
50
< hello
51
51
break in /home/indutny/Code/git/indutny/myscript.js:3
52
- 1 x = 5;
52
+ 1 global. x = 5;
53
53
2 setTimeout(() => {
54
- 3 debugger;
54
+ > 3 debugger;
55
55
4 console.log('world');
56
56
5 }, 1000);
57
57
debug> next
58
58
break in /home/indutny/Code/git/indutny/myscript.js:4
59
59
2 setTimeout(() => {
60
60
3 debugger;
61
- 4 console.log('world');
61
+ > 4 console.log('world');
62
62
5 }, 1000);
63
63
6 console.log('hello');
64
64
debug> repl
@@ -68,11 +68,11 @@ Press Ctrl + C to leave debug repl
68
68
> 2+2
69
69
4
70
70
debug> next
71
- < world
72
71
break in /home/indutny/Code/git/indutny/myscript.js:5
72
+ < world
73
73
3 debugger;
74
74
4 console.log('world');
75
- 5 }, 1000);
75
+ > 5 }, 1000);
76
76
6 console.log('hello');
77
77
7
78
78
debug> quit
@@ -121,24 +121,26 @@ is not loaded yet:
121
121
122
122
``` txt
123
123
$ node debug test/fixtures/break-in-module/main.js
124
- < debugger listening on port 5858
125
- connecting to port 5858... ok
124
+ < Debugger listening on 127.0.0.1: 5858
125
+ connecting to 127.0.0.1: 5858 ... ok
126
126
break in test/fixtures/break-in-module/main.js:1
127
- 1 var mod = require('./mod.js');
127
+ > 1 const mod = require('./mod.js');
128
128
2 mod.hello();
129
129
3 mod.hello();
130
- debug> setBreakpoint('mod.js', 23 )
130
+ debug> setBreakpoint('mod.js', 2 )
131
131
Warning: script 'mod.js' was not loaded yet.
132
- 1 var mod = require('./mod.js');
132
+ > 1 const mod = require('./mod.js');
133
133
2 mod.hello();
134
134
3 mod.hello();
135
+ 4 debugger;
136
+ 5
137
+ 6 });
135
138
debug> c
136
- break in test/fixtures/break-in-module/mod.js:23
137
- 21
138
- 22 exports.hello = () => {
139
- 23 return 'hello from module';
140
- 24 };
141
- 25
139
+ break in test/fixtures/break-in-module/mod.js:2
140
+ 1 exports.hello = function() {
141
+ > 2 return 'hello from module';
142
+ 3 };
143
+ 4
142
144
debug>
143
145
```
144
146
@@ -169,7 +171,8 @@ breakpoint)
169
171
170
172
### TCP-based protocol
171
173
172
- > Stability: 0 - Deprecated: Use [ V8 Inspector Integration] [ ] instead. The debug protocol used by the ` --debug ` flag was removed from V8.
174
+ > Stability: 0 - Deprecated: Use [ V8 Inspector Integration] [ ] instead.
175
+ The debug protocol used by the ` --debug ` flag was removed from V8.
173
176
174
177
An alternative way of enabling and accessing the debugger is to start
175
178
Node.js with the ` --debug ` command-line flag or by signaling an existing
@@ -188,8 +191,7 @@ localhost:5858
188
191
** NOTE: This is an experimental feature.**
189
192
190
193
V8 Inspector integration allows attaching Chrome DevTools to Node.js
191
- instances for debugging and profiling.
192
- It uses the [ Chrome Debugging Protocol] [ ] .
194
+ instances for debugging and profiling. It uses the [ Chrome Debugging Protocol] [ ] .
193
195
194
196
V8 Inspector can be enabled by passing the ` --inspect ` flag when starting a
195
197
Node.js application. It is also possible to supply a custom port with that flag,
@@ -203,9 +205,13 @@ $ node --inspect index.js
203
205
Debugger listening on port 9229.
204
206
Warning: This is an experimental feature and could change at any time.
205
207
To start debugging, open the following URL in Chrome:
206
- chrome-devtools://devtools/remote/serve_file/@60cd6e859b9f557d2312f5bf532f6aec5f284980/ inspector.html?experiments=true&v8only=true&ws=localhost :9229/node
208
+ chrome-devtools://devtools/bundled/ inspector.html?experiments=true&v8only=true&ws=127.0.0.1 :9229/dc9010dd-f8b8-4ac5-a510-c1a114ec7d29
207
209
```
208
210
211
+ (In the example above, the UUID dc9010dd-f8b8-4ac5-a510-c1a114ec7d29
212
+ at the end of the URL is generated on the fly, it varies in different
213
+ debugging sessions.)
214
+
209
215
[ Chrome Debugging Protocol ] : https://chromedevtools.github.io/debugger-protocol-viewer/
210
216
[ TCP-based protocol ] : #debugger_tcp_based_protocol
211
217
[ V8 Inspector Integration ] : #debugger_v8_inspector_integration_for_node_js
0 commit comments