Search code examples
node.jsnestjs

Nest.js @nestjs/platform-fastify,NestFastifyApplication<RawServerDefault>' does not satisfy the constraint 'INestApplication'


I'm using Nest.js, and I change express to fastify,but I got this error, NestFastifyApplication' does not satisfy the constraint 'INestApplication', I tried to uninstall @nestjs/platform-fastify, then install again, but still got this error,

this my 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(3000);
}
bootstrap();

I run nest info:

[Nest Platform Information]
platform-fastify version : 10.0.3
mapped-types version     : 2.0.2
schematics version       : 9.2.0
testing version          : 9.4.3
common version           : 9.4.3
core version             : 9.4.3
cli version              : 9.5.0

I don't know how to solve this error.


Solution

  • common, core, platform-fastify, and testing should all be on the same version. schematics and cli should be on the same major version. That should fix your issue