警告在检测到循环依赖时:barrelsby Angular 10

问题描述

在Angular 10中使用barrelsby时,我收到循环依赖警告。

**ENOENT: no such file or directory,scandir '/var/task/public/static/locales/es**

结构:

Error: 
WARNING in Circular dependency detected:
src\app\core\components\components.module.ts -> src\app\core\components\header\header.component.ts -> src\app\state\index.ts -> src\app\core\components\components.module.ts

/component /header header.component.ts index.ts

index.ts

export * from './header.component';

component.module.ts

import { HeaderComponent } from './header'; @NgModule({ imports: [],exports: [ HeaderComponent,],declarations: [ HeaderComponent ] })

index.ts

解决方法

这只是一个警告,因此您不需要完全修复它。警告会告诉您圆圈在哪里:

  • 从标头导入模块
  • 从索引导入标题
  • 从模块导入索引

为了打破圈子,我避免从索引导入。无论从索引导入哪个组件头,都应从该组件文件夹中导入它。