CrazySynthax
CrazySynthax

Reputation: 15018

How can I use readline-sync npm repository with WebStorm?

I wrote the following code using 'readline-sync' dependency.

var readlineSync = require('readline-sync');
function main() {
    printMenu();
    var userName = readlineSync.question('Please enter your choice:');
    console.log(userName);
}
main();

I ran this code from WebStorm trying to use the WebStorm console window. I got the error:

Error: The current environment doesn't support interactive reading from TTY. stty: when specifying an output style, modes may not be set

When I run it from linux terminal the code works with no error. I understand from the error message that 'readline-sync' cannot work from WebStorm console. Do you have any idea how to solve it?

Upvotes: 2

Views: 1328

Answers (1)

CrazySynthax
CrazySynthax

Reputation: 15018

I found out the answer.

  1. type in WebStorm terminal: $ node --debug-brk Web storm will give you the port number the debugger is listening to. On my machine it was 5858. Then press 'Ctrl+C'.

  2. Create a new debugging configuration as the following one: enter image description here

  3. In WebStorm terminal type again: "$ node --debug-brk main.js "

  4. put a breakpoint somewhere.
  5. Click the debugging icon enter image description here

Happy Debugging!

Upvotes: 2

Related Questions