简体   繁体   中英

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?

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: 在此处输入图片说明

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

  4. put a breakpoint somewhere.
  5. Click the debugging icon在此处输入图片说明

Happy Debugging!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM