Jaroslaw Nowak
Jaroslaw Nowak

Reputation: 115

Nestjs + TypeOrm autoLoadEntities or entities: ['dist/**/*.entity.js'] not working

I've created basic app in Nestjs and tried to setup a TypeORM but even if I have turned on autoLoadEntities or entities: ['dist/**/*.entity.js'] TypeORM is not synchronizing my database. My app.module looks like:

@Module({
  imports: [
    TypeOrmModule.forRoot({
      type: 'postgres',
      host: 'localhost',
      port: 5432,
      username: 'postgres',
      password: 'root',
      database: 'marketplace',
      entities: ['dist/**/*.entity.js'],
      synchronize: true,
    }),
    UserModule,
  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}

and directory structure is:

enter image description here

enter image description here

I saw few tutorials and they was using same config as me and same directory structure and after using npm run start:dev typeorm was creating tables in their database. Could you help me?

Upvotes: 1

Views: 2196

Answers (1)

Jaroslaw Nowak
Jaroslaw Nowak

Reputation: 115

I found a problem on github: https://github.com/typeorm/typeorm/issues/9766 The problem is with typeorm version 0.3.12. All I had to do is change typeorm version to 0.3.11 and wait to fix a bug. This problem occurs only on windows.

Upvotes: 1

Related Questions