Naveen DINUSHKA
Naveen DINUSHKA

Reputation: 1627

TypeError: Cannot read Property 'extend' of undefined , Yeoman Generator

I have installed yeoman generator and it is shown in the package.json file , but I get the above error pointing on the Base.^extend in the following line when i run yo my-generator-name

module.exports = generators.Base.extend

complete file looks so:

'use strict';

var generators = require('yeoman-generator');

module.exports = generators.Base.extend({
    method1: function(){
        this.log('Hello World');
    }
})

any help would be great!

Upvotes: 0

Views: 1209

Answers (1)

MinusFour
MinusFour

Reputation: 14423

It looks like that the extend method has been deprecated and removed by now. You'll have to use class syntax to extend the generator class.

v2.0.0

Breaking changes

Generator.extend() is replaced in favor of class extends Generator {}

const Generator = require('yeoman-generator');
module.exports = class extends Generator {
   /* your code here*/
}

Upvotes: 4

Related Questions