yeoman / generator-generator

Generate a Yeoman generator
1.22k stars 237 forks source link

instantiatedGenerator.run is not a function #258

Open houseBetter opened 7 months ago

houseBetter commented 7 months ago

cann't create an app。

image

node and package version

node v18.17.0 npm 9.6.7 yo 5.0.0 generator-generator 5.1.0

System

OS: macOS 12.6 CPU: (8) arm64 Apple M1

jedaan commented 7 months ago

getting the same error , any update ?

ekeel commented 7 months ago

I'm getting the same error as well.

Error generator 

instantiatedGenerator.run is not a function
Name Version
Node v20.10.0
NPM 10.2.3
yo 5.0.0
generator-generator 5.0.0/5.1.0

System

OS: Windows 11 22H2 CPU: Intel Core i9 RAM: 32GB

j4k0xb commented 7 months ago

Most likely introduced here: https://github.com/yeoman/environment/commit/3dc26947b70b686c87313ae64120584f3d8e26a2#diff-24984142d58a41889c987b60103bcd93653f3551f71f6cdf22b5762e885c9cd6L758

It didn't return a promise before image

jonathanwork commented 6 months ago

been getting the same error...

weshouman commented 6 months ago

Workaround I had to downgrade yo to get it working, for example

npm install -g yo@4.3.1 generator-generator
ruieloi commented 3 months ago

Hey! Any news about this issue? Is there another way for this to work except to downgrade? Did the method changed?

Thank you

takashi013 commented 3 months ago

any help ?

Aiwwa commented 3 months ago

Hello,

I'm also getting same error. Is this the dead end, or there some hopes ?

Thanks.

Vladyslav317 commented 2 months ago

Hi, any solutions except for downgrading?

AmroKhatib77 commented 1 month ago

hello, any solutions?

Aiwwa commented 1 month ago

We adjusted version and it worked

Pagarbiai

Aivaras Šavinis +370 (656) 69 221 @.*** http://www.linkedin.com/in/aivaras-savinis

On Mon, 6 May 2024 at 18:32, AmroKhatib77 @.***> wrote:

hello, any solutions?

— Reply to this email directly, view it on GitHub https://github.com/yeoman/generator-generator/issues/258#issuecomment-2096310387, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARCIZZMDIVUPIBRDFZEORATZA6PCPAVCNFSM6AAAAAA724UQ72VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJWGMYTAMZYG4 . You are receiving this because you commented.Message ID: @.***>

JosXa commented 1 month ago

Workaround I had to downgrade yo to get it working, for example

npm install -g yo@4.3.1 generator-generator

December 20. Project ded?

NgocLe1001 commented 1 month ago

npm install -g yo@4.3.1

Thanks It helps for mac M1 sonoma 14.4.1 (23E224)

NgocLe1001 commented 1 month ago

npm install -g yo@4.3.1

npm install -g yo@4.3.1 I resolved by installing this version. maybe you should try.

hcl-z commented 1 month ago

Check the yeoman-generator version that you use in your generator. This error is present in version 3. If you use JS to write your generator, try 5.10.0 instead, as higher versions only support esmodule

aliridha1510 commented 1 month ago

any solutions?

yenoh2 commented 4 days ago

I worked through detailed debugging to understand how to write a generator that works with the latest yeoman yo and generator. At this point none of the Yeoman documentation describes how to build a working generator with the latest version. I'm thinking this project needs to be updated in a similar way. Based on my efforts with my generator, it looks like this project needs to refactored to use import instead of require. Here's a fully functioning generator example that uses the latest version of yeoman and the yeoman generator: https://github.com/yenoh2/generator-hac-tf-module

  1. update your package.json adding "type": "module"
  2. Since the newer version uses ESM you need to update your generator use imports instead of 'require' in your index.js file. Example: import _ from 'lodash'; import Generator from 'yeoman-generator'; import askName from 'inquirer-npm-name'; import { createRequire } from 'module'; const require = createRequire(import.meta.url); // see full example here: https://github.com/yenoh2/generator-hac-tf-module/blob/master/generators/app/index.js
  3. Your export for your extended generator should look like this: export default class extends Generator {