【发布时间】:2019-12-19 18:33:30
【问题描述】:
first problem with JWT_MODULE_OPTION 之后,回到我认为已经解决的老问题。事实证明,当我“修复”旧问题时,会使用 JWT 创建新问题。
所以又无法编译:
Nest 无法解析 AuthService(?、RoleRepository、JwtService)的依赖关系。请确保索引 [0] 处的参数在 AppModule 上下文中可用。 +25 毫秒
这真的很奇怪,因为这种方式适用于我的另一个项目并且无法理解我错在哪里。这是auth.service.ts:
@Injectable()
export class AuthService {
constructor(
@InjectRepository(User) private readonly userRepo: Repository<User>,
@InjectRepository(Role) private readonly rolesRepo: Repository<Role>,
private readonly jwtService: JwtService,
) { }
它得到了角色和jwtService,但问题出在User,路径是正确的。这是app.module.ts:
@Module({
imports: [
TypeOrmModule.forRootAsync({
imports: [ConfigModule, AuthModule],
inject: [ConfigService],
useFactory: async (configService: ConfigService) => ({
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'],
}),
}),
],
controllers: [AppController, AuthController],
providers: [AuthService],
})
export class AppModule { }
对于控制器和提供者有相同的编译错误 & 无法理解出了什么问题...
【问题讨论】:
标签: javascript node.js typescript nestjs typeorm