我是 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/