简体   繁体   English

如何修复警告检测到循环依赖?

[英]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当我开始一个角度项目时,我每晚大约有 10 个错误而且我不明白这意味着什么

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 .例如,循环依赖是当A直接引用 B 时,反之亦然: A -> B -> A ,或间接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 .也许B中的模块可以移动到A或者AB引用的依赖项可以移动到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?我是否理解正确,您的 index.ts 正在被其他模块引用? 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. index.ts是项目的基础文件,不应被src文件夹中的任何其他内容引用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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