[英]I'm using JS in VScode and I'm trying to take user input through prompt cmd, but it's not working. I've already installed prompt-sync
I'm trying to write a simple code to take input from the user using the prompt cmd with the Node.js debugger in VScode, but nothing appears on the console, as if the code is forever running.我正在尝试编写一个简单的代码来使用提示 cmd 和 VScode 中的 Node.js 调试器从用户那里获取输入,但是控制台上什么也没有出现,就好像代码永远在运行一样。
What should I do?我应该怎么办?
I've already installed prompt-sync via Command Prompt using: npm install prompt-sync
.我已经通过命令提示符安装了 prompt-sync 使用: npm install prompt-sync
。
Also, I used const prompt = require('prompt-sync')();
另外,我使用const prompt = require('prompt-sync')();
as recommended by the README.md within the prompt-sync documentation.按照 prompt-sync 文档中 README.md 的建议。
However, when I write然而,当我写
const name = prompt('Whats your name? ');
console.log(`${name}`)
nothing happens on the DEBUG CONSOLE and the code never stops running. DEBUG CONSOLE 上没有任何反应,代码永远不会停止运行。
I had the same problem and solved adding我遇到了同样的问题并解决了添加
"console": "integratedTerminal"
to the launch.json in VSCode到 VSCode 中的 launch.json
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.