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.

EntityMetadataNotFound: No metadata for "User" was found. && I found that question in latest issues but i didnt see any solution, that helps me

See original GitHub issue

My ormconfig.ts

type: 'postgres',
host: "localhost",
port: 5432,
username: 'postgres',
password: "root",
database: "birji_db",
entities: ["dist/database/**/*.entity.js"],
factories: [ "dist/database/factories/**/*.js" ],
seeds: [ "dist/database/seeds/**/*.js"],
migrations: ["dist/migration/*.js"],
migrationsRun: true,
synchronize: true,
logging: true,
cli: {
    migrationsDir: 'src/database/migrations',
}

My structure image

What hapens

тЭМ Could not save entity EntityMetadataNotFound: No metadata for “User” was found. at new EntityMetadataNotFoundError (E:\projects\birji-backend\src\error\EntityMetadataNotFoundError.ts:10:9) at Connection.getMetadata (E:\projects\birji-backend\src\connection\Connection.ts:337:19) at E:\projects\birji-backend\src\persistence\EntityPersistExecutor.ts:76:55 at Array.forEach (<anonymous>) at EntityPersistExecutor.<anonymous> (E:\projects\birji-backend\src\persistence\EntityPersistExecutor.ts:70:30) at step (E:\projects\birji-backend\node_modules\typeorm\node_modules\tslib\tslib.js:141:27) at Object.next (E:\projects\birji-backend\node_modules\typeorm\node_modules\tslib\tslib.js:122:57) at E:\projects\birji-backend\node_modules\typeorm\node_modules\tslib\tslib.js:115:75 at new Promise (<anonymous>) at Object.__awaiter (E:\projects\birji-backend\node_modules\typeorm\node_modules\tslib\tslib.js:111:16) ├Ч Could not run the seed CreateUsers! Error: Could not save entity at EntityFactory.<anonymous> (E:\projects\birji-backend\node_modules\typeorm-seeding\src\entity-factory.ts:52:15) at step (E:\projects\birji-backend\node_modules\tslib\tslib.js:140:27) at Object.throw (E:\projects\birji-backend\node_modules\tslib\tslib.js:121:57) at rejected (E:\projects\birji-backend\node_modules\tslib\tslib.js:112:69) at processTicksAndRejections (internal/process/task_queues.js:97:5) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! birji-backend@0.0.1 seed:run: ts-node ./node_modules/typeorm-seeding/dist/cli.js seed -n src/database/orm.config.ts npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the birji-backend@0.0.1 seed:run script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\HP\AppData\Roaming\npm-cache_logs\2020-12-12T01_31_55_625Z-debug.log

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:6

github_iconTop GitHub Comments

2reactions
shahabgoharcommented, Apr 21, 2021

@ipirm Hello, i am able to solve this. your error suggest that it is looking for the metadata which is provided when you used annotations in your entity class (probably in user.entity.ts) with .ts. what you need to do is to change the location of entities just like this entities: ['src/**/*.entity{.ts,.js}'] also point your seeders and migrations to the ts files too or maybe with your locations do something like this entities: ['dist/**/*.entity{.ts,.js}'] and with other seeders and factories too

0reactions
jorgebodegacommented, Nov 25, 2021

I think the way you said this is disrespectful

I don’t know why typeorm & related libraries still follows this practice even though it was strictly forbidden many times

And I’m not sure those problems are enough reasons to change how this works. All of them are problems related to this library, but for those who use this library are not. Type-safety is working because seeders and entities must fulfill an interface.

Problems related to importing files using glob pattern should raise on applitacion startup and is responsibility of the user to maintain a proper way to name those files.

Again, if you are so sure that your way is better, please open an issue or a PR with examples.

Read more comments on GitHub >

github_iconTop Results From Across the Web

EntityMetadataNotFound: No metadata for "User" was found.
I'm following the documentation and pointing it to the src/entity/*.js location, but i keep getting the following error when running my server.
Read more >
No metadata for "User" was found using TypeOrm
Inserting a new user into the database... { EntityMetadataNotFound: No metadata for "User" was found. at new EntityMetadataNotFoundError (/Users ...
Read more >
typeorm entitymetadatanotfounderror: no metadata for was ...
Therefore, it didn't find the metadata when comparing it to manager.connection.entityMetadatas , which contained the old version only. The fix. I'll just need ......
Read more >
TypeORM - No metadata for "User" was found. - Reddit
TypeORM: EntityMetadataNotFound: No metadata for "User" was found. Hey all! Hoping some typeORM experts can help me out, burned wayyy to ...
Read more >
typeorm/typeorm - Gitter
Im not able to run PRAGMA foreign_keys=OFF in queryrunner using the query function as ... { EntityMetadataNotFound: No metadata for "User" was found....
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