Search code examples
node.jsyeomanyeoman-generator

Yeoman.io with nested prompts produces undefined error in Inquirer.js


I'm creating my first (real) Yeoman.io generator, which has some nested prompts (i.e. The answer of one prompt influences the presentation of other prompts and actions).

I've traced through my code, and on the surface it looks like I'm "opening and closing" my prompts appropriately, but at the very end of the script it looks like there's still an open readline (from Inquirer.js), and an extra onCompletion fires after the readlines have been closed.

I'm going to assume that this isn't a problem with the libraries (either Yeoman.io or Inquirer.js), it's a problem with the way that I'm prompting, or there's a different way to do what I'm trying to do.

INQUIRER onCompletion
Prompted for initialize, user said true
User said to initialize, exec git init
INQUIRER onCompletion
INQUIRER ERROR: TypeError: Cannot call method 'removeListener' of null
GITHOOKS PROMPT:  undefined
GITHOOKS PROMPT:  undefined

/untethered/app/index.js:178
        cb();
        ^
TypeError: undefined is not a function
    at UntetheredGenerator.<anonymous> (/untethered/app/index.js:178:3)
    at Object.<anonymous> (/untethered/node_modules/yeoman-generator/node_modules/inquirer/lib/inquirer.js:88:7)

Code is here: https://github.com/pollensoft/untethered/blob/master/app/index.js


Solution

  • Fixed here: github.com/pollensoft/untethered/commit/… SO won't let me answer my own question for 8 hours. If I forget to come back, this may appear unanswered. Way to go Stack Overflow! :)