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 issueMy 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

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:
- Created 3 years ago
- Reactions:2
- Comments:6

Top Related StackOverflow Question
@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 thisentities: ['dist/**/*.entity{.ts,.js}']and with other seeders and factories tooI think the way you said this is disrespectful
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.