Suppress “Circular dependency detected” suppress w

2020-08-26 11:28发布

问题:

I get the warning

Circular dependency detected!

in Angular 6 and I know why this problem appears, but it is not a problem at all.

I am currently working with SVG, and in my logic I prevent possible problems so I just want to suppress this warning. How can I do that?

I will fix this problem afterwards but for now I want to keep it because my code is more structured this way.

回答1:

Here the right path into the angular.json file :

projects -> architect -> options - > "showCircularDependencies": false


回答2:

It should be a problem, because it's like a recursive function with multiple components/modules. Ignoring the warning may cause a slow site, memory leaks, etc.

You may not notice anything at the moment, but it's bad practice, that you shouldn't get used to.

Here is an example, how your circular dependency could be resolved.

Edit:

If you want to disable the warning completely, you can do that by modifying your angular.json config file.

"defaults": {
    "apps": {
      "showCircularDependencies": false
    }
    "build": {
      "showCircularDependencies": false
    }
  }


回答3:

projects -> architect -> options - > "showCircularDependencies": false

@Marcello is correct that is the corrrect path...however if running "ng serve" you need to make sure to stop (Ctrl+C) and restart it for your angular.json file to be loaded or you will still get the circular dependency warnings.