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

TypeError: self.prompt is not a function when webpack-cli init #1226

Closed
terrencekhng opened this issue Apr 28, 2020 · 2 comments
Closed

TypeError: self.prompt is not a function when webpack-cli init #1226

terrencekhng opened this issue Apr 28, 2020 · 2 comments
Labels
needs triage Awaiting triage

Comments

@terrencekhng
Copy link

terrencekhng commented Apr 28, 2020

I'm currently learning how to build my own generator for webpack-cli following the instructions: https://webpack.js.org/contribute/writing-a-scaffold/

I tried to run webpack-cli init ../webpack-scaffold-react1, it seems to throw an error from Yeoman:

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

TypeError: self.prompt is not a function
    at List (/Users/hyaocuk/Documents/CS/Frontend/Scaffold/webpack-scaffold-react1/node_modules/@webpack-cli/webpack-scaffold/index.js:51:17)
    at WebpackGenerator.prompting (/Users/hyaocuk/Documents/CS/Frontend/Scaffold/webpack-scaffold-react1/index.js:18:13)
    at Object.<anonymous> (/Users/hyaocuk/Documents/CS/Frontend/Scaffold/webpack-scaffold-react1/node_modules/yeoman-generator/lib/index.js:816:25)
    at /Users/hyaocuk/Documents/CS/Frontend/Scaffold/webpack-scaffold-react1/node_modules/run-async/index.js:49:25
    at new Promise (<anonymous>)
    at /Users/hyaocuk/Documents/CS/Frontend/Scaffold/webpack-scaffold-react1/node_modules/run-async/index.js:26:19
    at runLoop.add.once.once (/Users/hyaocuk/Documents/CS/Frontend/Scaffold/webpack-scaffold-react1/node_modules/yeoman-generator/lib/index.js:817:11)
    at processImmediate (internal/timers.js:456:21)
Emitted 'error' event on WebpackGenerator instance at:
    at Immediate.<anonymous> (/Users/hyaocuk/Documents/CS/Frontend/Scaffold/webpack-scaffold-react1/node_modules/yeoman-generator/lib/index.js:852:20)
    at processImmediate (internal/timers.js:456:21)

the generator index.js

module.exports = class WebpackGenerator extends Generator {
/* constructor */
prompting() {
        return this.prompt([
            List('confirm', 'Welcome to the demo scaffold! Are you ready?', ['Yes', 'No', 'Pengwings']),
            Input('entry', 'What is the entry point in your app?')
        ]).then(answer => {
            if (answer['confirm'] === 'Pengwings') {
                this.options.env.configuration.dev.webpackOptions = createDevConfig(answer);
            }
        })
    }
}

I tried the latest @webpack-cli/init and @webpack-cli/init@0.2.2, but encountered the same error eventually.

Thank you~


I use nvm
Node: V14.0.0
npm: 6.14.4
yo: 3.1.1

@terrencekhng terrencekhng added the needs triage Awaiting triage label Apr 28, 2020
@mshima
Copy link
Member

mshima commented Apr 28, 2020

I don't know if I can help much here, but looking at: https://github.com/webpack/webpack-cli/blob/4fd900556ad1d9c87ca04fe0ebccb78dd89ea6c2/packages/webpack-scaffold/src/index.ts#L55-L61

Looks like it should be List(this, 'confirm', ... instead of List('confirm', ...

@terrencekhng
Copy link
Author

I don't know if I can help much here, but looking at: https://github.com/webpack/webpack-cli/blob/4fd900556ad1d9c87ca04fe0ebccb78dd89ea6c2/packages/webpack-scaffold/src/index.ts#L55-L61

Looks like it should be List(this, 'confirm', ... instead of List('confirm', ...

Thank you, @mshima, it shed light on how I'm going to resolve this issue, I should follow the instruction: https://yeoman.io/authoring/user-interactions.html
It's a little bit different from the one in webpack-cli.

Anyway, thank you very much! SOLVED

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

No branches or pull requests

2 participants