Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input prompt takes last answer on Nodejs 4.0.0 #282

Closed
rosen-vladimirov opened this issue Sep 9, 2015 · 13 comments
Closed

Input prompt takes last answer on Nodejs 4.0.0 #282

rosen-vladimirov opened this issue Sep 9, 2015 · 13 comments
Labels

Comments

@rosen-vladimirov
Copy link

Hi,

I've just tried using inquirer with latest Node - 4.0.0 and I've found an issue with consecutive input prompts. Here's the test case:

var inquirer = require("inquirer");
var question1 = {
    type: "input",
    message: "Enter something: ",
    name: "Failing_Node_4.0.0"
}

inquirer.prompt([question1], function( answers ) {
    // Use user feedback for... whatever!!
    console.log("First inquirer answered:", answers);
});

inquirer.prompt([question1], function( answers ) {
    // Use user feedback for... whatever!!
    console.log("Second inquirer answered:", answers);
});

When I enter some value in the first prompt, my answer is used for it and for the second input, so it is automatically resolved. I've tried this on Windows (cmd and Git Bash) and on Linux.
Same issue is reproduced with iojs 3.3.0 (tested on Linux only).

@SBoudrias
Copy link
Owner

Inquirer is asynchronous. You cannot run two prompt at the same time.

@rosen-vladimirov
Copy link
Author

Hi @SBoudrias ,
Thanks for pointing this. However we are using inquirer in synchronous code (by using fibers) and as I've tried to simplify the repro case, I've made mistake in the script that I've sent you. Here is the correct one:

var inquirer = require("inquirer");
var question1 = {
    type: "input",
    message: "Enter something: ",
    name: "Failing_Node_4.0.0"
}

inquirer.prompt([question1], function( answers ) {
    // Use user feedback for... whatever!!
    console.log("First inquirer answered:", answers);

    inquirer.prompt([question1], function( answers ) {
        // Use user feedback for... whatever!!
        console.log("Second inquirer answered:", answers);
    });
});

It is working fine on Node 0.12.x, but not on Node 4.0.0. The second inquirer calls the answers callback and accepts the same answer. After that the console is not released, it keeps waiting for input I think.

@SBoudrias SBoudrias reopened this Sep 9, 2015
@SBoudrias SBoudrias added the bug label Sep 9, 2015
@rosen-vladimirov
Copy link
Author

Just to add something - the second inquirer does not accept the same answer - it receives empty string as an answer.

@lsycxyj
Copy link

lsycxyj commented Sep 13, 2015

A bug similar to it. It works fine except Node 4.0.0. Arrow keys does not work in windows prompt.

  var inquirer = require('inquirer');
  inquirer.prompt([
    {
      type: "list",
      name: 'test',
      message: "test?",
      choices: [
        'A',
        new inquirer.Separator(),
        'B',
        new inquirer.Separator(),
        'C'
      ]
    }
  ]);

@Awk34
Copy link

Awk34 commented Sep 13, 2015

I have the same issue. I was trying to install Semantic UI, which uses gulp-prompt, which in turn uses Inquirer.js. My solution was to use Node.js 0.12.7 via nvm-windows, install Semantic UI, and then go back to using Node 4.0.0.

@SBoudrias
Copy link
Owner

Hey guys, I'll need more details because I just tested this on Window 10 (cmd.exe and Node 4.0) and everything is working fine.

I also copied your code example verbatim and it's working fine.

So please retry with the latest Inquirer version. Then give me:

  1. Code that I can run and that is failing for you on your computer.
  2. Windows version
  3. Node version
  4. Inquirer.js version
  5. Command line used to reproduce the bug

@LPGhatguy
Copy link

@Awk34 @lsycxyj that issue is reported for Windows at issue #266.

@jasoncmcg
Copy link

Nevermind, issue fixed when updated to node v4.1.1

This worked great on v0.12.x, but not on v4.x.x:

var inquire = require('inquirer');
var childProcess = require('child_process');

var chooseList = {
    type: "list",
    name: "whichProcess",
    message: "Which process to run?",
    choices: ["Option 1", "Option  2", "Option  3", "Option  4", "Option  5"]
}

inquire.prompt(chooseList, function (prompts) {
    switch (prompts.whichProcess) { //etc

I ran an npm update --save and have "inquirer": "^0.8.5" in the package file.

  • Windows 10
  • Node v4.0.0
  • Inquirer v0.8.5
  • Just running my script like this node .

Same problem as above. The arrow keys do not move up and down. I can hit enter and select the first entry.

@SBoudrias
Copy link
Owner

I'm going to close this issue as #266 have more feedback and is tracking the issue on Node side. Please continue further conversation over there.

@johnweland
Copy link

I actually have the same issue in Node 5.1.0

@ericis
Copy link

ericis commented Feb 10, 2016

Same. I also have the issue on Node 5.6.0

@kascode
Copy link

kascode commented Jun 7, 2016

Same issue. Node v.5.11.0

@projer-zz
Copy link

Same issue with 5.10.1 here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

10 participants