1

I have a lot of circular dependency errors in the angular project and unfortunately, my project doesn't run correctly.

How can I find which part of my program has circular dependency?

Warning: Circular dependency detected:
   src\app\@core\data\services\project-management\project\project-target.service.ts -> 
   src\app\@core\data\services\shared\data.service.ts -> src\app\auth\security.service.ts -> 
   src\app\@core\data\services\project-management\index.ts -> 
   src\app\@core\data\services\project-management\project\project-target.service.ts

enter image description here

Iman Bahrampour
  • 6,180
  • 2
  • 41
  • 64
davood beheshti
  • 213
  • 1
  • 11
  • 1
    Does this answer your question? [WARNING in Circular dependency detected - Angular Cli](https://stackoverflow.com/questions/47466147/warning-in-circular-dependency-detected-angular-cli) – Drenai Jun 12 '22 at 06:27

1 Answers1

0

It means classes or modules are referencing each other. While you should aim to avoid this, it's not always possible.

For example, a circular dependency is when A is directly referencing B and vice versa: A -> B -> A, or indirectly A -> B -> C -> A.

If possible, you should break this chain of dependency. Maybe the modules in B can be moved into A or maybe the dependencies that both A and B reference can be moved to C.

In your case, you can see both of direct and indirect circular referencing.

Do I understand it correctly, that your index.ts is being referenced by other modules? If so, that should not happen. index.ts is the base file of the project and shouldn't be referenced by anything else in the src folder.

Mads Akselsen
  • 249
  • 1
  • 5