generator-generator icon indicating copy to clipboard operation
generator-generator copied to clipboard

instantiatedGenerator.run is not a function

Open houseBetter opened this issue 2 years ago • 26 comments

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

houseBetter avatar Nov 26 '23 14:11 houseBetter

getting the same error , any update ?

jedaan avatar Dec 01 '23 10:12 jedaan

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

ekeel avatar Dec 01 '23 20:12 ekeel

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

  • https://github.com/yeoman/environment/pull/462
  • https://github.com/yeoman/yo/pull/793
  • https://github.com/yeoman/generator/pull/1478

It didn't return a promise before image

j4k0xb avatar Dec 03 '23 21:12 j4k0xb

been getting the same error...

jonathanwork avatar Dec 07 '23 06:12 jonathanwork

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

npm install -g [email protected] generator-generator

weshouman avatar Dec 20 '23 11:12 weshouman

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

Thank you

ruieloi avatar Mar 18 '24 10:03 ruieloi

any help ?

takashi013 avatar Mar 19 '24 13:03 takashi013

Hello,

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

Thanks.

Aiwwa avatar Mar 29 '24 12:03 Aiwwa

Hi, any solutions except for downgrading?

Vladyslav317 avatar Apr 11 '24 09:04 Vladyslav317

hello, any solutions?

AmroKhatib77 avatar May 06 '24 15:05 AmroKhatib77

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: @.***>

Aiwwa avatar May 06 '24 15:05 Aiwwa

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

npm install -g [email protected] generator-generator

December 20. Project ded?

JosXa avatar May 07 '24 21:05 JosXa

npm install -g [email protected]

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

NgocLe1001 avatar May 08 '24 15:05 NgocLe1001

npm install -g [email protected]

npm install -g [email protected] I resolved by installing this version. maybe you should try.

NgocLe1001 avatar May 08 '24 15:05 NgocLe1001

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

hcl-z avatar May 16 '24 06:05 hcl-z

any solutions?

aliridha1510 avatar May 21 '24 14:05 aliridha1510

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 {

yenoh2 avatar Jun 28 '24 23:06 yenoh2

Still getting this - is the project dead? Also, has anyone successfully implemented yenoh2's fix?

ralphcorrigan avatar Aug 09 '24 17:08 ralphcorrigan

Getting the same error. Any progress so far?

Either the project is dead or we need to get plop using EJS instead of handlebars.

LumiereLodi avatar Aug 27 '24 13:08 LumiereLodi

I had to roll back, but that worked. Looks like this version is bust (and the lack of response on the thread suggests the project is too)!

ralphcorrigan avatar Aug 27 '24 20:08 ralphcorrigan

Having the same issue.

soumilbaldota avatar Sep 04 '24 14:09 soumilbaldota

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

npm install -g [email protected] generator-generator

I´ve tried with this, it works. Thanks @Aiwwa

jarogamer56 avatar Sep 12 '24 18:09 jarogamer56

Running yo generator fails with

Error generator 

instantiatedGenerator.run is not a function

Environment:

node -v
v20.18.1

npm -v
11.0.0

yo --version
5.1.0

npm list -g generator-generator
/usr/local/share/nvm/versions/node/v20.18.1/lib
└── [email protected]

jozefizso avatar Dec 28 '24 12:12 jozefizso

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

what the ???? is it? I used the latest one 5.10 and still got this issue

ntt77 avatar Jan 24 '25 04:01 ntt77

👋 Hi all! We're resuming maintenance on Yeoman and picking up old issues like this one. See https://github.com/yeoman/yeoman/issues/1779.

I can reproduce this locally with:

npm i -g yo generator-generator
yo generator
yo generator
? Your generator name generator-yotest
? The name above already exists on npm, choose another? No
Your generator must be inside a folder named generator-yotest
I'll automatically create this folder.
(node:60092) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)

Just found a `.yo-rc.json` in a parent directory.
Setting the project root at: /Users/josh/repos/yotest
Error generator 

instantiatedGenerator.run is not a function

Digging through, I'm pretty sure the root cause is that generator-generator depends on a very old version of yeoman-generator:

https://github.com/yeoman/generator-generator/blob/f5b3ed87b7a785f85b64ec90de45fbfe88e6e273/package.json#L37

The variable name instantiatedGenerator no longer exists in the latest versions of yeoman-generator. In the Git history, the instantiatedGenerator.run line hasn't existed for a few years. It was refactored away starting in https://github.com/yeoman/generator/pull/1206: https://github.com/yeoman/generator/pull/1206/files#diff-92bbac9a308cd5fcf9db165841f2d90ce981baddcb2b1e26cfff170929af3bd1L941-R979 and continuing through a bunch of subsequent changes to the file.

I tried updating the yeoman-generator dependency to the latest ^7.4.0 but was hit with the always-lovely:

require() of ES Module /Users/josh/repos/generator-generator/node_modules/yeoman-generator/dist/index.js from /Users/josh/repos/generator-generator/app/index.js not supported.
Instead change the require of /Users/josh/repos/generator-generator/node_modules/yeoman-generator/dist/index.js in /Users/josh/repos/generator-generator/app/index.js to a dynamic import() which is available in all CommonJS modules.

...so using the latest yeoman-generator dependency is blocked on #265.


I can't promise exactly when we'll resolve #265 and unblock this issue, but I'm hoping it'll be Soon ™. In the meantime downgraded npm install -g [email protected] generator-generator does seem to fix this issue. I've hidden other comments in this thread to emphasize that. Cheers! 🎩

JoshuaKGoldberg avatar Jan 24 '25 12:01 JoshuaKGoldberg

up!

lorant-csonka-ICE avatar Feb 17 '25 10:02 lorant-csonka-ICE