{"record":{"id":"8dc09c73e51de280","repo":"nestjs/nest","slug":"nest-cannot-create-the-module-instance-often-thi","errorCode":null,"errorMessage":"Nest cannot create the module instance. Often, this is because of a circular dependency between modules. Use forwardRef() to avoid it.\n\n(Read more: https://docs.nestjs.com/fundamentals/circular-dependency)\nScope [${scope}]\n","messagePattern":"Nest cannot create the module instance\\. Often, this is because of a circular dependency between modules\\. Use forwardRef\\(\\) to avoid it\\.\n\n\\(Read more: https://docs\\.nestjs\\.com/fundamentals/circular-dependency\\)\nScope \\[(.+?)\\]\n","errorType":"exception","errorClass":"UndefinedForwardRefException","httpStatus":null,"severity":"error","filePath":"packages/core/injector/container.ts","lineNumber":106,"sourceCode":"\n  public getHttpAdapterHostRef() {\n    return this.internalProvidersStorage.httpAdapterHost;\n  }\n\n  public async addModule(\n    metatype: ModuleMetatype,\n    scope: ModuleScope,\n  ): Promise<\n    | {\n        moduleRef: Module;\n        inserted: boolean;\n      }\n    | undefined\n  > {\n    // In DependenciesScanner#scanForModules we already check for undefined or invalid modules\n    // We still need to catch the edge-case of `forwardRef(() => undefined)`\n    if (!metatype) {\n      throw new UndefinedForwardRefException(scope);\n    }\n    const { type, dynamicMetadata, token } =\n      await this.moduleCompiler.compile(metatype);\n    if (this.modules.has(token)) {\n      return {\n        moduleRef: this.modules.get(token)!,\n        inserted: false,\n      };\n    }\n\n    return {\n      moduleRef: await this.setModule(\n        {\n          token,\n          type,\n          dynamicMetadata,\n        },\n        scope,","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/nestjs/nest/blob/dd75d7bd8c5e88048587e6768d36eb695f3e7a25/packages/core/injector/container.ts#L88-L124","documentation":"Error \"Nest cannot create the module instance. Often, this is because of a circular dependency between modules. Use forwardRef() to avoid it.\n\n(Read more: https://docs.nestjs.com/fundamentals/circular-dependency)\nScope [${scope}]\n\" thrown in nestjs/nest.","triggerScenarios":"Thrown at packages/core/injector/container.ts:106 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"dd75d7bd8c5e88048587e6768d36eb695f3e7a25","analyzedAt":"2026-08-21T19:39:39.867Z","contentChangedAt":"2026-08-21T19:39:39.867Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}