为什么 Node.js 脚本控制台在 Windows 8 中会立即关闭? [英] Why does the Node.js scripts console close instantly in Windows 8?

查看:36
本文介绍了为什么 Node.js 脚本控制台在 Windows 8 中会立即关闭?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试了几乎所有我能找到的脚本示例.每个样本都会在瞬间打开终端.一旦输入输入,即使这也会关闭.这正常吗?

I've tried nearly every example for scripts I can find. Every sample opens the terminal for a split second. Even this closes as soon as input is entered. Is this normal?

    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();
});

推荐答案

在Tools/Options/Node.js Tools/General中有2个选项可以控制:

There are 2 options that control this in Tools/Options/Node.js Tools/General:

进程存在异常时等待输入进程正常存在时等待输入

Wait for input when process exists abnormally Wait for input when process exists normally

取自 https://nodejstools.codeplex.com/discussions/565665

这篇关于为什么 Node.js 脚本控制台在 Windows 8 中会立即关闭?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆