Circular Dependency — Fundamentals · NestJS

Resolve two modules and two providers that need each other with forwardRef(), and learn what native ES modules add to the docs' recipe.

What you will learn

Read the theory for Circular Dependency

All Fundamentals lessons

All NestJS courses

loading types…

What you'll learn

  • Recognise a circular dependency from the error it produces, at module level and at provider level
  • Resolve a module cycle and a provider cycle with forwardRef(), on both sides
  • Explain why, under native ES modules, the parameter's type must be a type-only import, and know the alternatives: ModuleRef and breaking the cycle