Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

571
Vistas
NestJs no puede crear una instancia del módulo (¿error de dependencias circulares?)

Tengo dos módulos que dependen uno del otro.

GameModule.ts

 import { Module, CacheModule, Global } from '@nestjs/common'; import { GameController } from './game.controller'; import { GameService } from './game.service'; import { PlayerModule } from '@src/player/player.module'; @Global() @Module({ imports: [ CacheModule.register(), PlayerModule, ], controllers: [GameController], providers: [GameService], exports: [CacheModule, GameService], }) export class GameModule {}

PlayerModule.ts

 import { Module, Global } from '@nestjs/common'; import { PlayerController } from './player.controller'; import { PlayerService } from './player.service'; import { GameModule } from '@src/game/game.module'; import { Web3ManagerModule } from '@src/web3-manager/web3-manager.module'; @Global() @Module({ imports: [GameModule, Web3ManagerModule], controllers: [PlayerController], providers: [PlayerService], exports: [PlayerService], }) export class PlayerModule {}

Definí en sus servicios el otro con forwardRef

GameService.ts

 ... constructor( @Inject(CACHE_MANAGER) private cacheManager: Cache, @Inject(forwardRef(() => PlayerService)) private playerService: PlayerService, ) { ...

PlayerService.ts

 ... constructor( @Inject(forwardRef(() => GameService)) private gameService: GameService, private web3Manager: Web3ManagerService, ) { ...

pero sigo recibiendo el error:

 Nest cannot create the GameModule instance. The module at index [1] of the GameModule "imports" array is undefined. Potential causes: - A circular dependency between modules. Use forwardRef() to avoid it. Read more: https://docs.nestjs.com/fundamentals/circular-dependency - The module at index [1] is of type "undefined". Check your import statements and the type of the module.

¿Qué me estoy perdiendo?

about 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda