pic*_*cus 2 javascript debugging node.js console.readline
我是Visual Studio Code,Javascript和Node.js的新手。
来自C#,我想使用在Debugging-console中设置的断点来调试类似的东西:
var name = Console.readline();
Console.Writeline(name);
Run Code Online (Sandbox Code Playgroud)
看起来很简单,但我失败了。我到目前为止发现的是
npm install sget
Run Code Online (Sandbox Code Playgroud)
我可以在集成终端中运行app.js,它将以交互方式工作。但这忽略了我的断点。
那么,如何使用readline功能和设置的断点呢?
x
编辑:谢谢暹罗,
我已经找到您引用的代码。放后
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();
});
Run Code Online (Sandbox Code Playgroud)
进入我的app.js并按F5键,Debug-Control-Panel会提示:
node --debug-brk=38079 --nolazy app.js
Debugger listening on [::]:38079
What do you think of Node.js?
Run Code Online (Sandbox Code Playgroud)
不幸的是,调试到此结束。无论我在该Debug-Control-Panel下面的命令行中填写什么,结果始终是
nicht verfügbar
Run Code Online (Sandbox Code Playgroud)
什么可能代表“不可用”。没有达到进一步的断点。
从单独的Powershell运行该代码将可以正常运行,但是当然不关心Debugger。
皮库斯
小智 8
如果您想在 VSCode 中使用终端,请将其添加到 launch.json 文件中的配置块中:
"console": "integratedTerminal"
这将允许您从控制台读取输入。您的调试点也将起作用。
确保您没有混淆地选择“internalConsole”,因为这将不允许您从程序中读取输入(请参阅下图)
| 归档时间: |
|
| 查看次数: |
1205 次 |
| 最近记录: |