Search code examples
node.jstypescriptnestjsdependency-managementfastify

NestJS: Type 'NestFastifyApplication' does not satisfy the constraint 'INestApplication'


I'm building a back-end application with NestJS and I'm trying to use fastify instead of express as the underlying framework. I'm following the documentation (available here) to use fastify, however I got the following type issue:

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

Here the code:

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();

Solution

  • The problem was simple. Something failed during the installation of @nestjs/platform-fastify. Just removing and installing the package was enough to solve