I can't comment, so I'm answering. I had the same problem.
I simplified the project to one basic entity. I tried both the TsMorphMetadataProvider and the ReflectMetadataProvider.
My tsconfig has:
"compilerOptions": {
"module": "NodeNext",
"moduleResolution": "NodeNext",
"target": "ES2022",
},
The error comes from: node_modules@nestjs\core\injector\injector.js:72
It only occurs when I define:
entities: ['./dist/**/*.entity.js'],
entitiesTs: ['./src/**/*.entity.ts'],
If I use the following, it will be fine:
entities: [TestEntity],
I'm not sure what is happening in NestJs at that moment though. I narrowed it down to MikroOrm because the exception is for moduleRef.name == 'MikroOrmCoreModule'
The debug log of MikroOrm states: processing 1 files, so it definitly finds the entity file.
I can't use the autoLoadEntities in my case. So I'll add the entities manually, but if someone can narrow down what's happening and how to solve it, that would be welcome.