Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug command line input in WebStorm

I have this simple program:

process.stdin.once("data", function (data) {
    console.log("You said your name is " + data);
    process.stdin.pause();
});
console.log("What is your name?");
process.stdin.resume();

Now I put a breakpoint inside a callback:

enter image description here

And run the program, the console tab is open:

enter image description here

But whatever I type into the terminal in this console tab doesn't trigger a breakpoint. It seems that this console tab is not a terminal used to accept input from a user.

like image 691
Max Koretskyi Avatar asked Dec 15 '16 09:12

Max Koretskyi


People also ask

How do I run debug mode in WebStorm?

To start debugging, hold Ctrl+Shift and click the link. WebStorm starts a debugging session with an automatically generated Attach to Node. js/Chrome configuration.

How do you add a breakpoint in WebStorm?

Click the gutter next to the executable line of code where you want to set a breakpoint. Alternatively, place the caret at this line and press Ctrl+F8 . To set a temporary line breakpoint, press Ctrl+Alt+Shift+F8 . The breakpoint will be removed from your project right after it is hit.


1 Answers

While debugging, make sure that "Use Console Input" toggle button on console's toolbar is NOT pressed - when it's pressed, console is in 'live' mode, all entered expressions are evaluated, so stdin is disabled.

enter image description here

like image 113
lena Avatar answered Oct 03 '22 22:10

lena