question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RepositoryNotFoundError when using HMR with TypeORM

See original GitHub issue

Bug Report

After following the Hot reload tutorial, then the TypeORM tutorial this error starts happening. I tried creating a new one from scratch to see if I had missed some step but the exact same error happened again. I have googled the error and none of the solutions seem to work, including the solutions talking about changing “entities” in configorm.json; I tried using sqlite and postgres but the same error happens with both.

When I run npm run build it creates the build succesfully so I assume it has something to do with HRM or/and webpack.

Current behavior

Get this error from console: RepositoryNotFoundError: No repository for “Photo” was found. Looks like this entity is not registered in current “default” connection?

Input Code

https://github.com/Ivanca/nestjs-error-proof

Expected behavior

No errors.

Environment


Nest version: 6.5.3

 
For Tooling issues:
- Node version: v10.16.0
- Platform: Windows 10

Others:
Package.json contains:
    "start": "ts-node -r tsconfig-paths/register dist/server",
    "webpack": "webpack --config webpack.config.js",

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
kamilmysliwieccommented, Aug 13, 2019

See the solution here: https://github.com/nestjs/nest/issues/755

@ecSpl01t it seems that for some reasons your entities are loaded twice. Perhaps, you just have to modify your entities path to don’t point at both .js and .ts files.

0reactions
kamilmysliwieccommented, Aug 14, 2019

This issue has nothing to do with NestJS. If you use bundler like webpack with typeorm, you have to either pass class references directly (instead of using a wildcard string which - for webpack - is just a string) OR create a plugin for webpack that would replace this particular string with those references at the compilation time.

Read more comments on GitHub >

github_iconTop Results From Across the Web

RepositoryNotFoundError when using HMR with TypeORM
I have googled the error and none of the solutions seem to work, including the solutions talking about changing "entities" in configorm.json; I ......
Read more >
TypeOrm:RepositoryNotFoundError in NestJS while seeding
I am trying to seed my database using NestJS and TypeORM. I have a migration file that creates an exercise table, and a...
Read more >
Getting TypeORM to work with Next.js and TypeScript
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. nestjs - You.com | The Search ...
Using Postman, when I attempt to hit a route, I am getting the following error: ... Inject TypeORM repository into NestJS service for...
Read more >
Graphql And Typeorm: "No Repository Was Found - ADocLib
I tried to use ts-node to compile TS modules on the fly as they get loaded by TypeORM, but then I got a...
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