EntityMetadataNotFoundError: No metadata for "UserRepository" was found
myvodx opened this issue ยท 8 comments
I got this error while registering new user & running e2e testing:
[Nest] 11896 - 09/10/2022, 3:27:48 PM ERROR [ExceptionsHandler] No metadata for "UserRepository" was found. EntityMetadataNotFoundError: No metadata for "UserRepository" was found.
I got this error while registering new user & running e2e testing:
[Nest] 11896 - 09/10/2022, 3:27:48 PM ERROR [ExceptionsHandler] No metadata for "UserRepository" was found. EntityMetadataNotFoundError: No metadata for "UserRepository" was found.
Please show your UserModule Code
I just follow the getting start:
# 1. Clone the repository or click on "Use this template" button.
npx degit NarHakobyan/awesome-nest-boilerplate my-nest-app
# 2. Enter your newly-cloned folder.
cd my-nest-app
# 3. Create Environment variables file & correct the value
cp .env.example .env
# 4. Install dependencies. (Make sure yarn is installed: https://yarnpkg.com/lang/en/docs/install)
yarn
# 5. Start application
yarn watch:dev
The userModule at https://github.com/NarHakobyan/awesome-nest-boilerplate/blob/main/src/modules/user/user.module.ts
Fix it by using custom repository, let's check it here: https://stackoverflow.com/questions/71557301/how-to-workraound-this-typeorm-error-entityrepository-is-deprecated-use-repo
It works fine now. Many thanks
guys don't use CustomRepository pattern, we struggle during the migration to the new version of nestjs.
Yeah! I look forward your new commit @NarHakobyan
Thank you for your help!
If you are having this issue still there are a couple of things you need to do in order to fix it.
Inside of the user.service.ts you need to replace private userRepository: UserRepository,
with @InjectRepository(UserEntity) private userRepository: Repository<UserEntity>,
Then after switching that out, you can go ahead and get rid of the user.repository.ts
file and change the import in the user.module.ts file from [TypeOrmModule.forFeature([UserRepository, UserSettingsRepository])],
to [TypeOrmModule.forFeature([UserEntity, UserSettingsEntity])],
@joshsisley all correct, I'll be glad if you can open PR to with this changes.