node.js - 如何将 readline-sync npm 存储库与 WebStorm 一起使用?

标签 node.js npm webstorm tty

我使用“readline-sync”依赖项编写了以下代码。

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

我从 WebStorm 运行此代码,尝试使用 WebStorm 控制台窗口。 我收到错误:

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

当我从 Linux 终端运行它时,代码运行没有错误。我从错误消息中了解到“readline-sync”无法在 WebStorm 控制台上工作。您知道如何解决吗?

最佳答案

我找到了答案。

  1. 在 WebStorm 终端中输入: $ Node --debug-brk Web Storm 将为您提供调试器正在监听的端口号。在我的机器上是 5858。然后按“Ctrl+C”。

  2. 创建一个新的调试配置,如下所示: enter image description here

  3. 在 WebStorm 终端中再次输入:“$ node --debug-brk main.js”

  4. 在某处放置断点。
  5. 单击调试图标 enter image description here

调试愉快!

关于node.js - 如何将 readline-sync npm 存储库与 WebStorm 一起使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41737166/

相关文章:

debugging - 如何使用 WebStorm 跨多个进程调试我的 Node 应用程序?

node.js - 运行 cucumberjs ft.selenium、phantomjs、webdriverio 时出错

node.js - MongoDB 中的用户特定数据库

javascript - 从哪里获得单个 lodash 包的@types?

node.js - 在 mac-os-x Yosemite 上调用 "npm"时 Jenkins 构建步骤失败

javascript - Angular 2 CLI 正在编译,但浏览器未反射(reflect)在 WebStorm 中所做的更改

javascript - Node.js 不支持 ES6 导入和导出

javascript - Expressjs 如何正确地从客户端传递数组并利用它?

node.js - 在 azure devops 中在管道作业级别拥有 .env 文件的最佳方法是什么

node.js - OpenShift :/lib64/libz. so.1 上的 NodeJS 应用程序:未找到版本 `ZLIB_1.2.9'