Inquirer.js: type: 'password' being shown while the second one was hidden

Created on 5 Dec 2017  路  5Comments  路  Source: SBoudrias/Inquirer.js

git bash

$ node -v
v8.9.1
$ npm -v
5.5.1
            .prompt([
                {
                  type: 'password',
                  mask: '*',            
                  message: 'Enter a password',
                  name: 'password'
                }
              ])
            .then(answers => console.log(JSON.stringify(answers)));

Output is the following

$ hei readDir
? Enter a password aaa
? Enter a password ***
{"password":"aaa"}

when i enter my password ,the password was showed on then terminal,and i pressed enter key ,it showed a new line with my password hidden

Most helpful comment

Oh, I'm so sorry! nodemon --no-stdin did the trick

All 5 comments

Unable to reproduce in the latest version using examples/password.js

Same happens to me. I debug a lot. Seems when ever you run js as bash. It not working as it suppose to work on git-bash.
can be reproduce

#!/usr/bin/env node

// rest of the code.
examples/password.js

I can reproduce this issue using nodemon 1.14.3:

gms@sirius:~/work/HOT/sandbox (master)$ ./node_modules/.bin/nodemon ./index.js 
[nodemon] 1.14.3
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node ./index.js`
? test password:  1234
? test password:  ****
testinput:  {
  "password": "1234"
}

but not, if I run the same code from node 8.9.4 directly:

gms@sirius:~/work/HOT/sandbox (master)$ node --version
v8.9.4
gms@sirius:~/work/HOT/sandbox (master)$ node ./index.js 
? test password:  ****
testinput:  {
  "password": "1234"
}

the code for the tests above:

const inquirer = require('inquirer');
inquirer.prompt([{name: 'password', type: 'password', message: 'test password: ', mask: '*'}]).then((answers) => {
  console.log(`testinput: `, JSON.stringify(answers, undefined, 2));
  return answers.password;
});

my shell is bash 4.4.12:

gms@sirius:~/work/HOT/sandbox (master)$ bash -version                          
GNU bash, Version 4.4.12(1)-release (x86_64-pc-linux-gnu)
...

Oh, I'm so sorry! nodemon --no-stdin did the trick

@gms1 yeah, highly probable Nodemon doesn't pipe a fully interactive prompt by default to the subprocess it spawns.

Any chance other people reporting this issue are also not running Inquirer through raw node process?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

apierzch picture apierzch  路  4Comments

ro31337 picture ro31337  路  5Comments

jahvi picture jahvi  路  6Comments

Ezekiel-DA picture Ezekiel-DA  路  7Comments

aaronshaf picture aaronshaf  路  7Comments