1.Start Node with debug
argument:
$ node debug yourscrupt.js
2.Run the debugger commands as you need.
If you want to debug in the browser, node-inspector is a good choice.
Question
this is one program written for nodeschool/stream-adventure/duplexer-redux. of course this is not gonna fulfill the requirement. But what I want to do is simply put a debugger there and watch what happens--just like set import ipdb; ipdb.set_trace in python. so what is the right way of doing this?
1 var duplexer = require('duplexer');
2 var through = require('through');
3
4 module.exports = function (counter) {
5 debugger;
6 var dic = {};
7 var tr = through(function (buf) {
8 if (dic[buf.country]) {
9 dic[buf.country] = 1;
10 } else {
11 dic[buf.country] = dic[buf.country] + 1;
12 }
13 });
14 counter.pipe(tr);
15
16 return tr;
17 }
18
Solution
1.Start Node with debug
argument:
$ node debug yourscrupt.js
2.Run the debugger commands as you need.
If you want to debug in the browser, node-inspector is a good choice.