首页 > 解决方案 > TYPEORM RepositoryNotFoundError:找不到“i”的存储库。看起来这个实体没有在当前的“默认”连接中注册?

问题描述

我正在尝试使用 orm 类型在数据库中设置用户。当我使用 typescript 时它工作得很好,但是当我用 parcel to js 构建它时,我不断收到这个错误:

RepositoryNotFoundError: No repository for "i" was found. Looks like this entity is not registered in current "default" connection?
    at new RepositoryNotFoundError (D:\GitHub\discord-bot-test\node_modules\typeorm\error\RepositoryNotFoundError.js:11:28)
    at EntityManager.getRepository (D:\GitHub\discord-bot-test\node_modules\typeorm\entity-manager\EntityManager.js:649:19)
    at Connection.getRepository (D:\GitHub\discord-bot-test\node_modules\typeorm\connection\Connection.js:367:29)
    at Object.getRepository (D:\GitHub\discord-bot-test\node_modules\typeorm\index.js:269:55)
    at D:\GitHub\discord-bot-test\bot.js:20:5065
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

而且我不知道为什么它不起作用,因为打字稿确实有效......

我不能把代码放在这里,因为它有很多字符......

有人可以单独帮助我解决这个问题吗?

标签: javascripttypescripttypeormparceljs

解决方案


对于那些使用nestjs的人,如果您没有在相应的模块中放置正确的导入,您可能会收到此错误:

@Module({
  imports:     [TypeOrmModule.forFeature([AaaEntity, BbbEntity, ...]

推荐阅读