NodeJS中的提示模块重复输入 [英] Prompt module in NodeJS repeating the input
问题描述
我正在使用 NodeJS 及其 CLI 应用程序制作应用程序;为了从用户那里获取输入,我正在使用提示"模块.我可以使用它,但是在输入提示时,每个字符都会重复,但是输出很好!代码如下.请帮忙.
I'm making an application using NodeJS and its a CLI application; to get the input from the user, I'm using the "prompt" module. I can use it, but while typing in the prompt's prompt, each character is getting repeated, however the output is fine! The code is below. Please Help.
prompt.start();
prompt.get({
properties: {
name: {
description: "What is your name?".magenta
}
}
}, function (err, result) {
console.log("You said your name is: ".cyan + result.name.cyan);
});
图片:
推荐答案
在使用提示"之前模块,我使用了 ReadLine 接口;可悲的是我遇到了同样的问题.但是,修复很简单:
Before using the "prompt" module, I used the ReadLine interface; sadly I had the same problem. However, the fix was simple:
删除rli.close();
然后运行它.
然后重新添加rli.close();
就可以了!
Then re-add the rli.close();
and it works!
感谢 mscdex 的输入,不过 :)
Thanks mscdex for the input, though :)
这篇关于NodeJS中的提示模块重复输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!