Component is part of the declaration of 2 modules

匿名 (未验证) 提交于 2019-12-03 01:27:01

问题:

I try to build an ionic 2 app. When I try the app in the browser with ionic serve or launch it on an emulator everything works fine.

But when I try to build it every time the error

ionic-app-script tast: "build" Error Type AddEvent in "PATH"/add.event.ts is part of the declarations of 2 modules: AppModule in "PATH"/app.modules.ts and AddEvent in "PATH"/add-event.module.ts. Please consider moving AddEvent in "PATH"/add-event.ts to a higher module that imports AppModule in "PATH"/app.module.ts and AddEventModule. You can also creat a new NgModule that exports and includes AddEvent then import that NgModule in AppModule and AddEventModule

my AppModule is

import { NgModule, ErrorHandler } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular'; import { AngularFireModule } from 'angularfire2'; import { MyApp } from './app.component'; import { Eventdata } from '../providers/eventdata'; import { AuthProvider } from '../providers/auth-provider'; import { HttpModule } from '@angular/http';  import { HomePage } from '../pages/home/home'; import { Login } from '../pages/login/login'; import { Register } from '../pages/register/register'; import { AddEvent } from '../pages/add-event/add-event'; import { EventDetails } from '../pages/event-details/event-details';  import { StatusBar } from '@ionic-native/status-bar'; import { SplashScreen } from '@ionic-native/splash-screen';   @NgModule({   declarations: [     MyApp,     HomePage,     Login,     Register,     AddEvent,     EventDetails    ],   imports: [     BrowserModule,     IonicModule.forRoot(MyApp),     HttpModule,     AngularFireModule.initializeApp(config)   ],   bootstrap: [IonicApp],   entryComponents: [     MyApp,     HomePage,     Login,     Register,     AddEvent,     EventDetails   ],   providers: [     StatusBar,     SplashScreen,     {provide: ErrorHandler, useClass: IonicErrorHandler}, Eventdata, AuthProvider   ] }) export class AppModule {}

and my add-event.module.ts is

import { NgModule }
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!