node.jsyeomanyeoman-generatoryeoman-generator-angular

Yeoman Generator cannot read property Base of undefined with 1.1 version


I started using the Yeoman Generators in which i'm building my own with the generator-generator and per a few tutorials I have a main index.js file in which this code is used

index.js

var yeoman = require('yeoman-generator');
var chalk = require('chalk');
var yosay = require('yosay');

module.exports = yeoman.generators.Base.extend({
.....

Yeoman generator that "works" is 0.19.0

packages.json

"dependencies": {
"yeoman-generator": "^0.19.0",

However, If I change to the latest version of Yeoman of 1.1.1 then it fails

cannot read property Base of undefined    
yeoman.generators.Base.extend

The stuff is all based on Node.js so i'm including it into the tags


Solution

  • As you might guess, 1.0 release came with some breaking change. You should refer to the official documentation: http://yeoman.io/authoring/

    // 0.x
    var Base = require('yeoman-generator').generators.Base;
    
    // 1.x
    var Base = require('yeoman-generator');
    

    Also see release notes: http://yeoman.io/blog/hello-generator-1.0.html