Search code examples
typescriptnestjs

NestJS / Typescript error TS2304 - Cannot find name 'Get'


I am getting this error to compile a file.

[ERROR] 17:58:11 ⨯ Unable to compile TypeScript: src/main.ts(5,6): error TS2304: Cannot find name 'Get'.

This is is my main.ts file

import {Controller, Module } from "@nestjs/common";
import {NestFactory} from "@nestjs/core";
@Controller()
class AppController {
    @Get()
    getRootRoute() {
        return "Hi, there!";
    }
}

@Module({
    controllers: [AppController]
})
class AppModule {}

async function bootstrap() {
    const app = await NestFactory.create(AppModule);

    await app.listen(3000);
}
bootstrap()

Solution

  • You need to import Get from the @nestjs/common package