javascript - Visual Studio Code 调试控制台中的 Node.js readline

标签 javascript node.js debugging console.readline

我是 Visual Studio Code、Javascript 和 Node.js 的新手。

来自 C# 我想调试类似这样的东西,在调试控制台中设置断点:

var name = Console.readline();
Console.Writeline(name);

看似很简单,但是我失败了。到目前为止我发现的是,在

npm install sget 

我可以在集成终端中运行 app.js,它将以交互方式运行。但这忽略了我的断点。

那么,我该如何使用 readline 功能和断点集呢?

谢谢 -piccus

编辑: 谢谢暹罗,

我已经找到您引用的代码。放置后

const readline = require('readline');

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

rl.question('What do you think of Node.js? ', (answer) => {
  // TODO: Log the answer in a database
  console.log(`Thank you for your valuable feedback: ${answer}`);

  rl.close();
});

进入我的 app.js 并按 F5,Debug-Control-Panel 提示:

node --debug-brk=38079 --nolazy app.js 
Debugger listening on [::]:38079
What do you think of Node.js? 

不幸的是,调试到此结束。无论我在 Debug-Control-Panel 下面的命令行中填写什么,结果总是

nicht verfügbar  

什么可能代表“不可用”。没有达到进一步的断点。

从单独的 powershell 运行该代码将正常运行,但当然不关心调试器。

画画

最佳答案

将此行添加到您的 launch.json 文件中:

"console": "externalTerminal" 

关于javascript - Visual Studio Code 调试控制台中的 Node.js readline,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41100916/

相关文章:

javascript - Node.jsexpress.Router导入新路由时出现ERR_MODULE_NOT_FOUND

javascript - fs.writeFile 没有错误,但写入文件失败

node.js - 如何处理 MongoDB 的断开连接错误

javascript - jquery ajax : redirect with json - unexplainable behaviour?

node.js - 将 Rust 与 Neon 绑定(bind)一起使用时,如何获得回溯或以其他方式调试 "failed to initiate panic"?

javascript - 选取框文本在刷新时发生变化

node.js - 在 mongo 中,是否有可能有一个看起来有效但永远不可能存在的 _id ?

regex - 空白字符正则表达式 chrome/nodejs

go - ldap搜索过滤器以检查特定域下是否存在任何用户

Javascript Tic Tac Toe Win Checker 很湿