我已经尝试了几乎所有可以找到的脚本的例子。每个样本都会打开终端一瞬间。输入输入后,即使这样也会关闭。这是正常的吗?
var rl = require('readline');
var prompts = rl.createInterface(process.stdin, process.stdout);
prompts.question("How many servings of fruits and vegetables do you eat each day? ", function (servings) {
var message = '';
if (servings < 5) {
message = "Since you're only eating " + servings +
" right now, you might want to start eating " + (5 - servings) + " more.";
} else {
message = "Excellent, your diet is on the right track!";
}
console.log(message);
process.exit();
});
答案 0 :(得分:0)
在Tools / Options / Node.js工具/常规中有两个选项可以控制它:
当进程异常存在时等待输入 当进程正常存在时等待输入