4

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()
1
  • 2
    Have you imported Get ? Commented Jan 5, 2023 at 17:07

2 Answers 2

7

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

Sign up to request clarification or add additional context in comments.

Comments

0

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

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.