I'm failed to compile with this error:
Nest can't resolve dependencies of the JWT_MODULE_OPTIONS (?). Please make sure that the argument at index [0] is available in the JwtModule context. +52ms
I saw similar dependencies problems with modules & services, but they didn't work for me. Using JwtModule in my auth.module.ts:
import { JwtModule } from '@nestjs/jwt';
@Module({
imports: [
TypeOrmModule.forFeature([User, Role]),
ConfigModule,
PassportModule.register({ defaultStrategy: 'jwt' }),
JwtModule.registerAsync({
inject: [ConfigService],
useFactory: async (configService: ConfigService) => ({
secretOrPrivateKey: config.jwtSecret,
type: configService.dbType as any,
host: configService.dbHost,
port: configService.dbPort,
username: configService.dbUsername,
password: configService.dbPassword,
database: configService.dbName,
entities: ['./src/data/entities/*.ts'],
signOptions: {
expiresIn: config.expiresIn,
},
}),
}),
],
providers: [AuthService, JwtStrategy],
controllers: [AuthController],
})
export class AuthModule { }
I have no idea how to fix this bug... Using jwt 6.1.1
Edit: In my previous project use jwt 6.0.0, so I downgrade it, but problem not fix.