Error "Unhandled 'error' event" after running yo generator
Asked Answered
M

3

5

I am trying to use the generator of generatos, the generator-generator, and I am facing an error.

henrique@liberato:~/Documents$ yo generator
? Your generator name (generator-documents) 

events.js:154
      throw er; // Unhandled 'error' event
      ^

TypeError: this.env.adapter.prompt(...).then is not a function
    at Base.prompt (/home/henrique/.nvm/versions/node/v5.8.0/lib/node_modules/generator-generator/node_modules/yeoman-generator/lib/base.js:232:45)
    at askName (/home/henrique/.nvm/versions/node/v5.8.0/lib/node_modules/generator-generator/node_modules/inquirer-npm-name/lib/index.js:25:19)
    at module.exports.generators.Base.extend.prompting (/home/henrique/.nvm/versions/node/v5.8.0/lib/node_modules/generator-generator/app/index.js:21:12)
    at Object.<anonymous> (/home/henrique/.nvm/versions/node/v5.8.0/lib/node_modules/generator-generator/node_modules/yeoman-generator/lib/base.js:431:23)
    at /home/henrique/.nvm/versions/node/v5.8.0/lib/node_modules/generator-generator/node_modules/run-async/index.js:26:25
    at /home/henrique/.nvm/versions/node/v5.8.0/lib/node_modules/generator-generator/node_modules/run-async/index.js:25:19
    at /home/henrique/.nvm/versions/node/v5.8.0/lib/node_modules/generator-generator/node_modules/yeoman-generator/lib/base.js:432:9
    at processImmediate [as _immediateCallback] (timers.js:383:17)

Versions:

henrique@liberato:~/Documents$ node -v
v5.8.0
henrique@liberato:~/Documents$ npm -version
3.8.9

I already did npm cache clean and npm install -g yo/yeoman-generator/generator-generator. Already reinstaled node and npm.

Thanks for your time :)

Mozzetta answered 12/5, 2016 at 17:28 Comment(0)
U
11

You need to update yo to the latest version.

npm -g update yo

And if that doesn't work, then you want:

npm -g uninstall yo
npm -g install yo
Unsuspecting answered 12/5, 2016 at 18:48 Comment(4)
neither worked for me.. my node environment is managed by nvm. Currently i am using node v6.2.0Saccharo
@Chandru sounds to me like you have two npm installed. which yo and running DEBUG=yeoman:* yo will give you more information as to which paths are used.Unsuspecting
yes. you are right. i had multiple npms and the path I have installed yo was different from my current npm path. So, I had to switch to the previous version of node and continue using generator commands.Saccharo
You can do this: npm uninstall -g yo && npm uninstall -g generator-generator npm install -g yo && npm install -g generator-generatorAquinas
S
1

I had similar issue. However, updating or re-installing yo didn't help me.

My node environment is managed by nvm, where I am currently using node v6.2.0. However, yo was installed long ago in my pc while I was using node v4.4.1. When I used v4.4.1, I didnt get the error.

So, conclusion is that the yo angular-fullstack commands are working in the same node version in which it was installed. As nvm is handy in switching between node version, its not a big deal for me. I use v4.4.1 only when i generate some angular components, and switch back to the latest version.

Saccharo answered 8/6, 2016 at 11:19 Comment(0)
V
0

I had this issue too. I'm also using nvm to manage my node versions.

In my case, some combination of npm dedupe -g, npm update -g yo, npm uninstall -g yo, and npm install -g yo did the trick. I also re-reran npm link from my generator, since it is a local generator. I think if it's a generator you installed from npm, npm uninstall -g <generator-name> followed by `npm install -g would serve the same purpose.

At some point during all this, the generator started working again, but I didn't notice exactly when, because I was running the generator as a part of my unit tests.

Eventually, I realized that the generator was working when I ran it from the command line, but not when I ran it from my test files.

At that point, updating yeoman's test helpers (npm update yeoman-test) from 1.1.0 to 1.4.0 did the trick.

Vasiliki answered 29/6, 2016 at 18:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.