You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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. Here's a fully functioning example that uses the latest version of yeoman and the yeoman generator: https://github.com/yenoh2/generator-hac-tf-module
update your package.json adding "type": "module"
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
Your export for your extended generator should look like this:
export default class extends Generator {
Type of issue
Bug report
My environment
macOS 14.4.1
20.10.0
(runnode --version
in your terminal)10.2.3
(runnpm --version
in your terminal)5.0.0
(runyo --version
in your terminal)Expected behavior
Should proceed with generating a project by adding src folder
Current behavior
generator.run is not a function
Steps to reproduce the behavior
yo
the name of the generator
Command line output
The text was updated successfully, but these errors were encountered: