toonvanstrijp / nestjs-i18n

The i18n module for nestjs.
https://nestjs-i18n.com
Other
652 stars 112 forks source link

Nest can't resolve dependencies of the I18nOptions after upgrade to nest 6.3.1 #5

Closed rzimmer closed 5 years ago

rzimmer commented 5 years ago

Hi @ToonvanStrijp,

We are using the async module inititialization like this:

@Module({
  imports: [
    ConfigModule,
    I18nModule.forRootAsync({
      imports: [ConfigModule],
      useExisting: ConfigService,
    }),
  ],
  providers: [TranslationService],
  exports: [TranslationService],
})
export class TranslationModule {}

This worked well until we upgraded to version 6.3.1 (was 6.2.4). I suspect, https://github.com/nestjs/nest/issues/2341 boke something. We also use https://github.com/nestjs/jwt/ and initialize it in a very similiar way:

@Module({
  imports: [
    ConfigModule,
    JwtModule.registerAsync({
      imports: [ConfigModule],
      useExisting: ConfigService,
    }),
    PassportModule.register({ defaultStrategy: 'jwt' }),
    UserModule,
  ],
  controllers: [AuthController],
  providers: [AuthService, JwtStrategy, LocalStrategy],
  exports: [AuthService],
})
export class AuthModule {}

This works flawless even with 6.3.1. I'm not an expert with nest modules, but looking at the source code of JwtModule, I suspect https://github.com/nestjs/jwt/blob/master/lib/jwt.module.ts#L26 is needed for this to work. A similiar imports entry is missing in I18nModule's declaration, so this might be the reason why above configuration is not working. Can you provide a fix or should I try create a PR?

toonvanstrijp commented 5 years ago

@rzimmer fixed it in version 2.1.4 (made 2 version jump because I messed up the npm publish once)

welljs commented 11 months ago

The same problem with Nestjs:9.x.x and nestjs-i18n:10.3.7

nishad-mahajan-sp commented 3 months ago

facing same issue any solution ?