Taimur Ajmal
Taimur Ajmal

Reputation: 2855

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

Upvotes: 3

Views: 1932

Answers (2)

Marz m
Marz m

Reputation: 11

u neeed to import {Get} the dependencies from @nestjs/common

Upvotes: 0

Jay McDoniel
Jay McDoniel

Reputation: 70061

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

Upvotes: 6

Related Questions