No repository for "s" was found. Looks like this entity is not registered in current "default" connection?

See original GitHub issue

I’m submitting a…


[ ] Regression 
[ ] Bug report
[ ] Feature request
[x] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

I’m using webpack and nestjs + postgres. In development mode, It’s worked OK but in production, I got error as below.

No repository for "s" was found. Looks like this entity is not registered in current "default" connection?

This is my config.

return {
      type: "postgres",
      host: this.getValue("POSTGRES_HOST"),
      port: parseInt(this.getValue("POSTGRES_PORT")),
      username: this.getValue("POSTGRES_USER"),
      password: this.getValue("POSTGRES_PASSWORD"),
      database: this.getValue("POSTGRES_DATABASE"),

      entities: ["**/*.entity{.ts,.js}"],

      migrationsTableName: "migration",

      migrations: ["./dist/src/migration/*.ts"],

      cli: {
        migrationsDir: "./dist/src/migration"
      }
    };

I searched around and change entities: ["**/*.entity{.ts,.js}"], to entities: ["dist/**/*.entity{.ts,.js}"], or entities: ["./dist/**/*.entity{.ts,.js}"],… but not luck.

Expected behavior

Worked on both of env.

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Environment


Nest version
```
    "@nestjs/common": "^6.8.0",
    "@nestjs/core": "^6.8.0",
    "@nestjs/passport": "^6.1.1",
    "@nestjs/platform-express": "^6.8.0",
    "@nestjs/swagger": "^3.1.0",
    "@nestjs/typeorm": "^6.2.0",
```

 
For Tooling issues:
- Node version: 12.3.1  
- Platform:  Mac 

Others:

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

13reactions
etienne-martincommented, Jul 29, 2020

Try giving a name to your entity with the @Entity decorator:

import { Entity, PrimaryColumn, Column } from "typeorm";

@Entity("category") // <-- Right here
export class Category {
  @PrimaryColumn({ type: "varchar", length: 255 })
  slug: string;

  @Column({ type: "varchar", length: 255, unique: true })
  url: string;

  @Column({ type: "varchar", length: 255 })
  name: string;
}
4reactions
raysercast1commented, Oct 30, 2020

Try giving a name to your entity with the @Entity decorator:

import { Entity, PrimaryColumn, Column } from "typeorm";

@Entity("category") // <-- Right here
export class Category {
  @PrimaryColumn({ type: "varchar", length: 255 })
  slug: string;

  @Column({ type: "varchar", length: 255, unique: true })
  url: string;

  @Column({ type: "varchar", length: 255 })
  name: string;
}

I was having the same problem and this solved it. Thank you! @etienne-martin

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: RepositoryNotFoundError: No repository for [Enitity] ...
RepositoryNotFoundError is throw in case your entity isnt properly registered in connections. This could be caused wrong path (glob pattern) in ...
Read more >
No repository for "User" was found. Looks like this entity is ...
RepositoryNotFoundError : No repository for "User" was found. Looks like this entity is not registered in current "default" connection? Typeorm.
Read more >
typeorm/typeorm - Gitter
"RepositoryNotFoundError: No repository for "MyModelName" was found. Looks like this entity is not registered in current "default" connection?".
Read more >
How to Configure TypeORM to Work in Transpiled ...
RepositoryNotFoundError : No repository for "User" was found. Looks like this entity is not registered in current "default" connection?
Read more >
no metadata for repository was found
EntityMetadataNotFound error is displayed when TypeORM cant find your entities. Often this is caused by wrong/misspelled entry in your ormconfig file. If you ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found