Error: Schematic "rest" cannot resolve the factory

82 Views Asked by At

function looks like this:

I am using first time nestjs for generators, it seems like i have some issue in collection.json

export function application(options: any) {
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
  return (_tree: Tree, _context: SchematicContext) => {
    return chain([
      externalSchematic('@nestjs/schematics', 'application', options),
      generate(options),
    ]);
  };
}
export function generate(_options: any): Rule {
  return (tree: Tree, context: SchematicContext) => {
    return chain([
      addDependencies(tree, _options),
      renderTemplates(_options),
      modifyGeneratedFiles(_options),
    ])(tree, context);
  };
} 

collection.json file looks like this.

  "schematics": {

    "resolver": {

      "description": "Nodejs GraphQL project scaffold",

      "factory": "./resolver-generator/index#application",

      "schema": "./resolver-generator/resolver-schema.json"

    },

    "rest": {

      "description": "Nodejs Rest generator project scaffold",

      "factory": "./rest-generator/index#applicationRest",

      "schema": "./rest-generator/rest-schema.json"

    }
1

There are 1 best solutions below

0
Krish909 On

Thank you for help i am able to solve it, it was happening bcoz of wrong function name when we use nestjs/schematics we have to pass application not applictionRest