title: How use external entities in nestjs project with typeorm?
body: <p>I'm trying to use type orm entities defined outside of the project. That is,  I have two projects: models and core-api. Models is an npm package that exports the entities definition. So, from core-api(nestjs project) i'm trying to define the connection using those entities. Something like this:</p>
  
  <pre><code>@Module({
      imports: [ TypeOrmModule.forRoot({
      type: 'postgres',
      host: 'postgres',
      port: 5432,
      username: 'myuser',
      password: 'mypass',
      database: 'mydb',
      entities: [
          __dirname + '../node_modules/something/models/src/*.entity.ts'
      ],
      synchronize: true,
      }), AModule ],
      controllers: [],
      providers: [],
  })
  export class AppModule {}
  </code></pre>
  
  <p>Then, in A module, I'm importing the A entity from the npm package:</p>
  
  <pre><code>import { Module } from '@nestjs/common';
  import { TypeOrmModule } from '@nestjs/typeorm';
  import { AsController } from './As.controller';
  import { AsService } from './As.service';
  import { A } from 'something/models';
  
  @Module({
    imports: [TypeOrmModule.forFeature([ A ])],
    controllers: [AController],
    providers: [AService],
  })
  export class AModule {}
  </code></pre>
  
  <p>This ends up with the next error:</p>
  
  <p><code>RepositoryNotFoundError: No repository for "A" was found. Looks like this entity is not registered in current "https://stackoverflow.com/a/54191513/3943197https://stackoverflow.com/a/54191513/3943197default" connection?</code></p>
  
  <p>I'm quite lost in how to follow since i don't understand how it works under the hood. I saw the code of typeorm and @nestjs/typeorm but I couldn't figure out how to solve it.</p>
  
  <p>Thanks!</p>
  
  <p><strong>UPDATE:</strong>
  I could make it work adding the entity class instead of a path like @serianox said. Also, the <code>something/models</code> npm package exports a standalone nest module. This module import/export the entities defined on the package. Thus, I could inject the entities on the main application.</p>