所以我的问题是,我得到一个错误:

(node:12319) UnhandledPromiseRejectionWarning: Error: Nest can't resolve dependencies of the undefined (?). Please make sure that the argument at index [0] is available in the current context.
    at Injector.lookupComponentInExports (/.../node_modules/@nestjs/core/injector/injector.js:129:19)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:12319) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with.catch(). (rejection id: 1)
(node:12319) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.


事件模块

@Module({
  imports: [MiteApiModule, TypeOrmModule.forFeature([EventEntity])],
  controllers: [EventController],
  providers: [EventService],
  exports: [EventService]
})
export class EventModule implements NestModule {
  configure(consumer: MiddlewareConsumer): void | MiddlewareConsumer {
    return consumer.apply(logger, AuthMiddleware).forRoutes(EventController);
  }
}

export function logger(req, res, next) {
  console.log(`Request...`);
  next();
}


用户模块

@Module({
  imports: [MiteApiModule, TypeOrmModule.forFeature([User])],
  controllers: [UserController],
  providers: [UserService],
  exports: [UserService]
})
export class UserModule implements NestModule {
  configure(consumer: MiddlewareConsumer): void | MiddlewareConsumer {
    return consumer.apply(logger, AuthMiddleware).forRoutes(UserController);
  }
}

export function logger(req, res, next) {
  console.log(`Request...`);
  next();
}


验证模块

@Module({
  controllers: [AuthController],
  providers: [AuthService],
  imports: [MiteApiModule, UserModule, EventModule],
  exports: []
})
export class AuthModule {}


但是,如果我没有EventModule就运行,则node.js / nest应用程序正在运行。我不知道我在想什么。任何想法,谢谢吗?

最佳答案

我的解决方案是将UserModule导入到EventModule

10-05 20:36
查看更多