2

I want to debug a simple nodejs readline programme.

var readline = require("readline");
var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

rl.question("What's your name \n",function(answer){
    var x =10;  // set the break point here
    console.log("your name is ",answer);
    rl.close();
});

I set the break point at var x = 10; inside callback function of rl.question().but the break point never hits.

Why this happening I am confused.
Then how to debug a readline programme.

2 Answers 2

3

Have you tried using node-inspector? I was able to debug fine from there. If your program is terminal-based, using a web-based debugger and thus leaving the terminal available for the app might avoid some confusion and trickiness.

screen grab of node-inspector

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

Comments

1

I use

node --inspect yourFile.js

which outputs: Debugger listening on ws://127.0.0.1:9229/abcXXX-....

I access it through Vivaldi, Chrome or Opera using: vivaldi://inspect or chrome://inspect

On this page it shows 'Remote Targets' and you click inspect on yourFile. That opens basically the same debugger you use in the web console.

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.