【发布时间】:2022-01-11 22:27:00
【问题描述】:
尝试在用户模型和组之间建立链接时,出现错误:
我不明白为什么..
[Nest] 30312 - 06.12.2021, 20:53:42 LOG [NestFactory] Starting Nest application...
[Nest] 30312 - 06.12.2021, 20:53:42 ERROR [ExceptionHandler] Nest cannot create the AuthModule instance.
The module at index [1] of the AuthModule "imports" array is undefined.
Potential causes:
- A circular dependency between modules. Use forwardRef() to avoid it. Read more: https://docs.nestjs.com/fundamentals/circular-dependency
- The module at index [1] is of type "undefined". Check your import statements and the type of the module.
Scope [AppModule]
Error: Nest cannot create the AuthModule instance.
The module at index [1] of the AuthModule "imports" array is undefined.
app.module.ts https://pastebin.com/T9EC05gS
users.module.ts https://pastebin.com/inS044Xk
user.model.ts https://pastebin.com/wpyUs2SW
groups.module.ts https://pastebin.com/Jvr2Fuk3
group.model.ts https://pastebin.com/nBvkaEUt
auth.module.ts https://pastebin.com/MYQ2dw6y
auth.guard.ts https://pastebin.com/xDpQ8vwE
auth.service.ts https://pastebin.com/G9TzN3XF
提前致谢
更新: 添加时出现错误
@Expose()
@HasMany(() => Group)
groups: Group[];
到 user.model.ts
【问题讨论】:
-
最好添加实际代码sn-ps而不是代码链接。虽然链接可以提供一些额外的上下文,但它们在问题的上下文中是不可搜索的,这使得问题更难找到
-
我想以这种方式添加代码(直接进入问题),但网站说问题中有很多代码..
标签: typescript dependency-injection nestjs circular-dependency sequelize-typescript