title: TypeORM Entity in NESTJS - Cannot use import statement outside a module
body: <p>Started new project with 'nest new' command. Works fine until I add entity file to it.</p>
  
  <p>Got following error:</p>
  
  <blockquote>
    <p>import { Entity, Column, PrimaryGeneratedColumn } from 'typeorm';</p>
    
    <p>^^^^^^</p>
    
    <p>SyntaxError: Cannot use import statement outside a module</p>
  </blockquote>
  
  <p>What do I miss?</p>
  
  <p>Adding Entity to Module:</p>
  
  <pre><code>import { Module } from '@nestjs/common';
  import { BooksController } from './books.controller';
  import { BooksService } from './books.service';
  import { BookEntity } from './book.entity';
  import { TypeOrmModule } from '@nestjs/typeorm';
  
  @Module({
    imports: [TypeOrmModule.forFeature([BookEntity])],
    controllers: [BooksController],
    providers: [BooksService],
  })
  export class BooksModule {}
  </code></pre>
  
  <p>app.module.ts:</p>
  
  <pre><code>import { Module } from '@nestjs/common';
  import { AppController } from './app.controller';
  import { AppService } from './app.service';
  import { TypeOrmModule } from '@nestjs/typeorm';
  import { Connection } from 'typeorm';
  import { BooksModule } from './books/books.module';
  
  @Module({
    imports: [TypeOrmModule.forRoot()],
    controllers: [AppController],
    providers: [AppService],
  })
  export class AppModule {}
  </code></pre>