My compilation failed with the following error message:
Nest can't resolve dependencies of the JWT_MODULE_OPTIONS (?). Please ensure that the argument at index [0] is available in the JwtModule context. +52ms
I encountered similar issues regarding dependencies with modules and services, but the suggested solutions didn't work for me. I am 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 am unsure how to resolve this bug... Currently using jwt 6.1.1
Edit: In my previous project, I utilized jwt 6.0.0, therefore I downgraded it, however, the issue persisted.