admin管理员组

文章数量:1295322

I'm encountering an issue with NestJS dependency injection, where Nest can't resolve dependencies of CriticalDataElementService due to UserService at index 1.

Error:

Nest can't resolve dependencies of the CriticalDataElementService (CriticalDataElementRepository, ?, NotificationService, AuditService, OrganizationService). 
Please make sure that the argument UserService at index [1] is available in the CriticalDataElementModule context.

Potential solutions:
- Is CriticalDataElementModule a valid NestJS module?
- If UserService is a provider, is it part of the current CriticalDataElementModule?
- If UserService is exported from a separate @Module, is that module imported within CriticalDataElementModule?
  @Module({
    imports: [ /* the Module containing UserService */ ]
  })

My Setup: CriticalDataElementService depends on multiple services, including UserService. UserService is defined in a separate module. I'm using @Injectable() for all services and ensuring they are in their respective modules.

What I’ve Tried: ✅ Ensured UserService is inside its own module with @Injectable(). ✅ Exported UserService in its module and imported that module inside CriticalDataElementModule. ✅ Checked that CriticalDataElementModule is correctly structured.

本文标签: