{"id":513,"hash":"9c8b17f09e6f64348658b08e417a06aec4f7f8fef5fa631944e7a9ee90fee669","pattern":"RepositoryNotFoundError: No repository for &quot;User&quot; was found. Looks like this entity is not registered in current &quot;default&quot; connection? Typeorm","full_message":"I am having a fun issue trying to get TypeOrm to work in my nestjs project.\n\nI have the below code to configure my project, yes everything loads, and yes I am able to connect to my database.\n\nimport { CacheModule, Module } from '@nestjs/common';\nimport { JwtModule } from '@nestjs/jwt';\nimport { PassportModule } from '@nestjs/passport';\nimport { TypeOrmModule } from '@nestjs/typeorm';\nimport { User } from './entities/user.entity';\nimport { ConfigModule } from '@nestjs/config';\nimport { AuthenticationController } from './controllers/authentication.controller';\nimport { AuthenticationService } from './services/authentication.service';\nimport { Connection } from 'typeorm';\nimport { BaseEntity } from './entities/base.entity';\n\n@Module({\n  imports: [\n    ConfigModule.forRoot(),\n    TypeOrmModule.forRoot({\n        type: 'postgres',\n        host: 'localhost',\n        port: 5432,\n        username: 'postgres',\n        password: process.env.POSTGRE_PASSWORD,\n        database: process.env.DATABASE,\n        migrationsTableName: 'migration_table',\n        entities: [User, BaseEntity],\n        migrations: [__dirname + '/migrations/**/*.ts'],\n        subscribers: [__dirname + '/subscribers/**/*.ts'],\n        cli: {\n          entitiesDir: '/entitys',\n          migrationsDir: '/migrations',\n          subscribersDir: '/subscribers',\n        },\n        synchronize: true,\n        autoLoadEntities: true,\n    }),\n    CacheModule.register(),\n    PassportModule,\n    JwtModule.register({\n      secret: 'myprivatekey',\n      signOptions: { expiresIn: '1d' },\n    }),\n  ],\n  controllers: [AuthenticationController],\n  providers: [AuthenticationService],\n})\nexport class AppModule {\n  constructor(private connection: Connection) {}\n}\n\nand here are the entities:\n\nimport {\n  Column,\n  BeforeUpdate,\n  BeforeInsert,\n} from 'typeorm';\n\nexport class BaseEntity {\n  @Column()\n  created_at: Date;\n\n  @Column({\n    default: new Date(),\n  })\n  updated_at: Date;\n\n  @BeforeUpdate()\n  updateUpdatedAt() {\n    this.updated_at = new Date();\n  }\n\n  @BeforeInsert()\n  updateCreatedAt() {\n    this.created_at = new Date();\n  }\n}\n\nimport {\n  Entity,\n  Column,\n  PrimaryGeneratedColumn,\n  Generated,\n} from 'typeorm';\n\nimport { BaseEntity } from './base.entity';\n\n@Entity('users')\nexport class User extends BaseEntity {\n  @PrimaryGeneratedColumn()\n  id: number;\n\n  @Column()\n  @Generated('uuid')\n  uuid: string;\n\n  @Column()\n  first_name: string;\n\n  @Column()\n  last_name: string;\n\n  @Column()\n  email: string;\n\n  @Column()\n  password: string;\n\n  @Column({\n    default: false,\n  })\n  confirmed: boolean;\n\n  @Column({\n    default: null,\n  })\n  seller_id: string;\n\n  @Column({\n    default: null,\n  })\n  auth_token: string;\n\n  @Column({\n    default: false,\n  })\n  is_admin: boolean;\n}\n\nI originally tried doing a glob pattern match, to no avail, so now I am directly importing in my Entities until I can get something to run. Also note, that all my modules load prior to the error above and the error is from using the @InjectRepository() decorator within either the AuthenticationController or AdminController. Everywhere I have looked has said its because my entities are not being loaded, which I am not sure how that is possible. Thanks.","ecosystem":"npm","package_name":"node.js","package_version":null,"solution":"In my case I had an error on Production mode, to fix it I added the path of the compiled JS files in the build folder.\n\nconst conn: MongoConnectionOptions = {\n  type: 'mongodb',\n  url: DB_URL,\n  synchronize: true,\n  useNewUrlParser: true,\n  useUnifiedTopology: true,\n  logging: true,\n  entities: ['src/entity/*.ts', './build/src/entity/*.js'], // <- Here!\n  migrations: ['src/migration/**/*.ts'],\n  subscribers: ['src/subscriber/**/*.ts'],\n  cli: {\n    entitiesDir: 'src/entity',\n    migrationsDir: 'src/migration',\n    subscribersDir: 'src/subscriber',\n  },\n  extra: {\n    authSource: DB_AUTH_SOURCE,\n  },\n};\n\nThe short version could be: entities: ['**/src/entity/*{.ts,.js}'],","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/65336801/repositorynotfounderror-no-repository-for-user-was-found-looks-like-this-ent","votes":28,"created_at":"2026-04-19T04:51:16.279773+00:00","updated_at":"2026-04-19T04:51:16.279773+00:00"}