0

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

5
  • github.com/node-inspector/node-inspector Commented Feb 22, 2014 at 4:51
  • Have you gotten a debugger attached? What's actually going wrong? Commented Feb 22, 2014 at 6:56
  • should not the program execution stops when it hits debugger? @Aaron Dufour Commented Feb 22, 2014 at 9:40
  • Do you start Node with debug argument? Commented Feb 22, 2014 at 9:45
  • thanks--now I understand. but is there anyway i can stop the execution of node half way? I am using an external testing script file and it is a bit troublesome to manually type "node debug" as some input is provided by the script Commented Feb 22, 2014 at 13:07

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.