简体   繁体   中英

how to fix warning Circular dependency detected?

have a good time

I have about 10 errors a night when I start an angular project And I do not understand what it means

How can I fix this error?

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

在此处输入图像描述

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM