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.

ts-node throwing RepositoryNotFoundError

See original GitHub issue

Here is the example repo. https://github.com/zackarychapple/flagger

When I am starting the server with nodemon everything initializes correctly however when seed tries to run it bombs out with the below error. I tried several paths for mapping to my entities however it seems none of them pick up. Any thoughts?

(node:99829) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): RepositoryNotFoundError: No repository for "FlagsEntity" was found. Looks like this entity is not registered in current "default" connection?
(node:99829) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:18 (3 by maintainers)

github_iconTop GitHub Comments

86reactions
chriszrccommented, Sep 21, 2017

I also had the same No repository for ... in current "default" connection and it worked fine for development (running with nodemon), but failed after tsc compilation running under node. I had to change:

entities: [
          __dirname + '/../**/**.entity.ts'
 ],

to:

entities: [
          __dirname + '/../**/**.entity{.ts,.js}'
 ],

I see a reference to this in the typeorm docs, is this the prescribed way for dealing with entities in typescript? (https://typeorm.github.io/connection.html#creating-connection)

6reactions
pleerockcommented, Sep 22, 2017

no, it depends how you run your app. If you are running via ts-node then you can use “.ts” files as entities. If you aren’t using ts-node then you must specify “.js” files. And you need to make sure to specify proper output directory (if you are using outDir tsc option) to ensure paths to your generated js files are correct.

Read more comments on GitHub >

github_iconTop Results From Across the Web

RepositoryNotFoundError : TypeORM - Stack Overflow
ts used when locally running with ts-node; js used when having built for ... but during the run time, it's going to throw...
Read more >
Troubleshooting | ts-node - TypeStrong · GitHub
This error is thrown by node when a module has an unrecognized file extension, or no extension at all, and is being executed...
Read more >
Graphql And Typeorm: "No Repository Was Found - ADocLib
TypeORM version: Test with: mocha --require ts-node/register '. RepositoryNotFoundError is throw in case your entity isnt properly registered in My solution ...
Read more >
Complete guide to using TypeORM and TypeScript for data ...
npm install typescript ts-node --save-dev ... throw new Error(`Student id ${util.inspect(id)} did not retrieve a Student`); }
Read more >
Getting TypeORM to work with Next.js and TypeScript
I tried to use ts-node to compile TS modules on the fly as they get loaded ... RepositoryNotFoundError: No repository for "User" was...
Read more >

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