Search code examples
angularbuildproduction

angular build --prod error


Type src/app/createreportcomponent component.ts is part of the declarations of 2 modules Error but the normal development build is working fine. How to fix the Error

****App Module ts file****

import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import { AngularDualListBoxModule } from 'angular-dual-listbox';

import { HomeComponent } from './home/home.component';
import { CreatereportComponent } from './createreport/createreport.component';
import { AppRoutingModule } from './app-routing.module';

import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { HashLocationStrategy, LocationStrategy } from '@angular/common';
import { HttpModule } from '@angular/http';

import { Angular2CsvModule } from 'angular2-csv';

// import {ToastModule} from 'ng2-toastr/ng2-toastr';

import { CommonService } from './services/common.service';

@NgModule({
  declarations: [
    AppComponent,
    HomeComponent,
    CreatereportComponent
  ],
  imports: [
     BrowserModule,
     AngularDualListBoxModule,
    BrowserAnimationsModule,
    AppRoutingModule,
    HttpModule,
    FormsModule,
    Angular2CsvModule,
   // ToastModule.forRoot(),
  ],
  providers: [{provide: LocationStrategy, useClass: HashLocationStrategy},CommonService],
  bootstrap: [AppComponent]
})
export class AppModule { }

Create Component ts file


Solution

  • If you are using 'createreportcomponent' in another module then removed it from main module.