У меня есть пользовательский модуль и модуль автофинала в моем проекте Nest. p>
**Error: Nest can't resolve dependencies of the AuthService (?, AuthRepository, JwtService, ConfigService, JwtService, SendgridService). Please make sure that the argument dependency at index [0] is available in the AuthModule context.
Potential solutions:
- Is AuthModule a valid NestJS module?
- If dependency is a provider, is it part of the current AuthModule?
- If dependency is exported from a separate @Module, is that module imported within AuthModule?
@Module({
imports: [ /* the Module containing dependency */ ]
})**
this is my code:
< /code>
@Injectable()
export class UserService {
constructor(
private readonly userRepository: UserRepository,
private readonly verificationService: VerificationService,
private eventEmitter: EventEmitter2,
private readonly authService: AuthService, < -- its errors when i add this.
private readonly sendgridService: SendgridService,
) {}
}
< /code>
@Module({
imports: [
TypeOrmModule.forFeature([User, Role]),
forwardRef(() => AuthModule),
VerificationModule,
SendgridModule,
],
controllers: [UserController],
providers: [UserService, UserRepository],
exports: [UserService, UserRepository],
})
export class UserModule {}
< /code>
@Module({
imports: [
TypeOrmModule.forFeature([Token]),
JwtModule.registerAsync({
inject: [ConfigService],
useFactory: async (configService: ConfigService) => ({
secret: configService.get('JWT_SECRET'),
signOptions: { expiresIn: GeneralMessage.JWT_TOKEN_EXPIRES_TIME },
}),
}),
forwardRef(() => UserModule),
SendgridModule,
],
controllers: [AuthController],
providers: [AuthService, AuthRepository],
exports: [AuthService, AuthRepository],
})
export class AuthModule {}
< /code>
How i searched forwardRef must help in this case, i added it but am getting same error...
Подробнее здесь: https://stackoverflow.com/questions/794 ... -injection