admin管理员组文章数量:1200985
I'm new to Visual Studio Code, Javascript and Node.js.
Coming from C# I want to debug something like this with breakpoints set in Debugging-console:
var name = Console.readline();
Console.Writeline(name);
It seems to be so simple, but I fail. What I found so far is, that after
npm install sget
I can run app.js in integrated terminal and it will work interactively. But that ignores my breakpoints.
So, how can I work with readline-functionality and breakpoints set?
Thx -piccus
EDIT: Thank you Siam,
I already found the Code you referenced. After putting
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();
});
into my app.js and pressing F5, the Debug-Control-Panel prompts:
node --debug-brk=38079 --nolazy app.js
Debugger listening on [::]:38079
What do you think of Node.js?
Unfortunately that is the end of Debugging. Whatever I fill into the commandline below that Debug-Control-Panel, the result is always
nicht verfügbar
what probably stands for 'not available'. No further breakpoint is being reached.
Running that Code from seperate powershell will run as it should, but of Course does not care about Debugger.
piccus
I'm new to Visual Studio Code, Javascript and Node.js.
Coming from C# I want to debug something like this with breakpoints set in Debugging-console:
var name = Console.readline();
Console.Writeline(name);
It seems to be so simple, but I fail. What I found so far is, that after
npm install sget
I can run app.js in integrated terminal and it will work interactively. But that ignores my breakpoints.
So, how can I work with readline-functionality and breakpoints set?
Thx -piccus
EDIT: Thank you Siam,
I already found the Code you referenced. After putting
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();
});
into my app.js and pressing F5, the Debug-Control-Panel prompts:
node --debug-brk=38079 --nolazy app.js
Debugger listening on [::]:38079
What do you think of Node.js?
Unfortunately that is the end of Debugging. Whatever I fill into the commandline below that Debug-Control-Panel, the result is always
nicht verfügbar
what probably stands for 'not available'. No further breakpoint is being reached.
Running that Code from seperate powershell will run as it should, but of Course does not care about Debugger.
piccus
Share Improve this question edited Dec 12, 2016 at 16:24 piccus asked Dec 12, 2016 at 12:25 piccuspiccus 1712 silver badges9 bronze badges3 Answers
Reset to default 16Add this line to you launch.json file:
"console": "externalTerminal"
If you want to use a terminal within VSCode then add this to the configuration block in your launch.json file:
"console": "integratedTerminal"
This will allow you to read input from the console. Your debug points will work too.
Make sure that you don't select "internalConsole" in confusion as that won't allow you to read input from a program (refer to the image below)
What you exactly wanna achieve? Do you wanna read line from console and echo back to you? Maybe this will help. https://nodejs.org/api/readline.html
本文标签: javascriptNodejs readline in debugconsole in Visual Studio CodeStack Overflow
版权声明:本文标题:javascript - Node.js readline in debug-console in Visual Studio Code - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738602081a2102127.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论