首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Typescript错误中的类型AnimatesDirective是2个模块声明的一部分

Typescript错误中的类型AnimatesDirective是2个模块声明的一部分
EN

Stack Overflow用户
提问于 2018-06-07 03:00:12
回答 1查看 416关注 0票数 -1

当我使用下面的CLI时,它显示错误。错误消息对我来说不清楚。

代码语言:javascript
复制
> ionic cordova run android --prod --device

错误:

代码语言:javascript
复制
 typescript error
            Type AnimatesDirective in
            D:/Freelance-Work/Clients/ionic3/node_modules/css-animator/angular/animates.directive.d.ts
            is part of the declarations of 2 modules: AppModule in
            D:/Freelance-Work/Clients/ionic3/src/app/app.module.ts and AnimatorModule in
            D:/Freelance-Work/Clients/ionic3/node_modules/css-animator/angular/animator.module.d.ts!
            Please consider moving AnimatesDirective in
            D:/Freelance-Work/Clients/ionic3/node_modules/css-animator/angular/animates.directive.d.ts
            to a higher module that imports AppModule in
            D:/Freelance-Work/Clients/ionic3/src/app/app.module.ts and AnimatorModule in
            D:/Freelance-Work/Clients/ionic3/node_modules/css-animator/angular/animator.module.d.ts. You
            can also create a new NgModule that exports and includes AnimatesDirective in
            D:/Freelance-Work/Clients/ionic3/node_modules/css-animator/angular/animates.directive.d.ts
            then import that NgModule in AppModule in
            D:/Freelance-Work/Clients/ionic3/src/app/app.module.ts and AnimatorModule in
            D:/Freelance-Work/Clients/ionic3/node_modules/css-animator/angular/animator.module.d.ts.

Error: The Angular AoT build failed. See the issues above
    at D:\Freelance-Work\Clients\ionic3\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:237:55
    at step (D:\Freelance-Work\Clients\ionic3\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:32:23)
    at Object.next (D:\Freelance-Work\Clients\ionic3\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:13:53)
    at fulfilled (D:\Freelance-Work\Clients\ionic3\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:4:58)
    at <anonymous>

你能告诉我如何解决这个问题吗?

app.module.ts

代码语言:javascript
复制
import { AnimationService, AnimatesDirective } from 'css-animator';

@NgModule({
  declarations: [
    MyApp,
    AnimatesDirective
  ],
  imports: [
    BrowserModule,
    IonicModule.forRoot(MyApp),
    HttpClientModule,
    AppConfigModule,
    IonicStorageModule.forRoot()
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
   ],
  providers: [
    StatusBar,
    SplashScreen,
    NativeStorage,
    { provide: ErrorHandler, useClass: IonicErrorHandler },
    AnimationService,   
  ]
})
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-06-07 04:32:18

似乎你的应用程序中有两个模块,并在这两个模块中都声明了AnimatesDirective。从app.module.ts中删除声明,但更新app.module.ts配置以导入另一个模块。

app.module.ts

代码语言:javascript
复制
import { AnimatorModule } from 'css-animator';

@NgModule({
  declarations: [
    MyApp,
  ],
  imports: [
    BrowserModule,
    IonicModule.forRoot(MyApp),
    HttpClientModule,
    AppConfigModule,
    IonicStorageModule.forRoot(),
    AnimatorModule
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
  ],
  providers: [
    StatusBar,
    SplashScreen,
    NativeStorage,
    { provide: ErrorHandler, useClass: IonicErrorHandler },
  ]
})
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50727735

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档