【问题标题】:NestJS: Type 'NestFastifyApplication' does not satisfy the constraint 'INestApplication'NestJS:类型“NestFastifyApplication”不满足约束“INestApplication”
【发布时间】:2021-09-02 17:00:04
【问题描述】:

我正在使用 NestJS 构建一个后端应用程序,并且我正在尝试使用 fastify 而不是 express 作为底层框架。我正在按照文档 (available here) 使用 fastify,但是我遇到了以下类型问题:

Type 'NestFastifyApplication' does not satisfy the constraint 'INestApplication'.

Type 'NestFastifyApplication' is missing the following properties from type
'INestApplication': use, enableCors, enableVersioning, listenAsync, and 22 more

代码如下:

import { NestFactory } from '@nestjs/core';
import {
  FastifyAdapter,
  NestFastifyApplication,
} from '@nestjs/platform-fastify';
import { AppModule } from './app.module';

async function bootstrap() {
  const app = await NestFactory.create<NestFastifyApplication>(
    AppModule,
    new FastifyAdapter(),
  );
  await app.listen(3001);
}
bootstrap();

【问题讨论】:

    标签: node.js typescript nestjs dependency-management fastify


    【解决方案1】:

    问题很简单。安装@nestjs/platform-fastify 时出现故障。只需删除和安装软件包即可解决

    【讨论】:

    • @ErangaHeshan 我知道,但是 Stackoverflow 要求我等待 2 天
    猜你喜欢
    • 2021-01-28
    • 2019-09-19
    • 2020-10-25
    • 2021-05-13
    • 2021-04-15
    • 1970-01-01
    • 2020-07-07
    • 1970-01-01
    • 2022-11-10
    相关资源
    最近更新 更多