[英]Node.js readline in debug-console in Visual Studio Code
我是 Visual Studio Code、Javascript 和 Node.js 的新手。
来自 C# 我想用在 Debugging-console 中设置的断点来调试这样的东西:
var name = Console.readline();
Console.Writeline(name);
看起来很简单,但我失败了。 到目前为止我发现的是,之后
npm install sget
我可以在集成终端中运行 app.js,它将以交互方式工作。 但这忽略了我的断点。
那么,我如何使用 readline 功能和断点集?
Thx -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?
不幸的是,调试结束了。 无论我在调试控制面板下面的命令行中填写什么,结果总是
nicht verfügbar
什么可能代表“不可用”。 没有到达进一步的断点。
从单独的 powershell 运行该代码将按原样运行,但当然不关心调试器。
皮克斯
将此行添加到您的 launch.json 文件中:
"console": "externalTerminal"
你到底想达到什么目的? 你想从控制台读取一行并回显给你吗? 也许这会有所帮助。 https://nodejs.org/api/readline.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.