Ionic build browser --prod --release showing error when I build for PWA


#1

My app.module.ts file is


import { IonTextAvatarComponent } from '../components/ion-text-avatar/ion-text-avatar';
import { ProgressBarComponent } from '../components/progress-bar/progress-bar';
import { FlashCardComponent } from '../components/flash-card/flash-card';
import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';
import { IonicStorageModule } from '@ionic/storage';


import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';
im
import { ContentPage } from '../pages/content/content';
import { TrainingPage } from '../pages/training/training';

import { AuthProvider } from '../providers/auth/auth';

import { TrainingContentPage } from '../pages/training-content/training-content';

import { DataProvider } from '../providers/data/data';

import { HttpModule, Http } from '@angular/http';
import { HttpClientModule } from '@angular/common/http';
import { SanitizePipe } from '../pipes/sanitize/sanitize';
// import { TextAvatarDirective } from '../directives/text-avatar/text-avatar';
// import { IonTextAvatar } from 'ionic-text-avatar';


// import { NavController } from 'ionic-angular';
@NgModule({
  declarations: [
    MyApp,
    HomePage,
    ProgressBarComponent,
    TrainingContentPage,
    QuizPage,
    FlashCardComponent,
    SanitizePipe,
    IonTextAvatarComponent
  ],
  imports: [
    BrowserModule,
    IonicModule.forRoot(MyApp),
    IonicStorageModule.forRoot(),
    HttpModule,
    HttpClientModule,
    
    
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    HomePage,
    TrainingContentPage,
    QuizPage,
    
    
    
  ],
  providers: [
    StatusBar,
    SplashScreen,
    {provide: ErrorHandler, useClass: IonicErrorHandler},
    AuthProvider,
    IonicStorageModule,
    DataProvider,
    HttpModule,
    Http,
    HttpClientModule,
    
  ]
})
export class AppModule {}

When i run ionic build browser --prod --release its showing

[WARN] ionic build is for building web assets and takes no arguments. See ionic build --help.

       Ignoring argument browser. Perhaps you meant ionic cordova build browser?


Running app-scripts build: --prod
[18:38:29]  build prod started ...
[18:38:29]  clean started ...
[18:38:29]  clean finished in less than 1 ms
[18:38:29]  copy started ...
[18:38:29]  deeplinks started ...
[18:38:29]  deeplinks finished in 46 ms
[18:38:29]  ngc started ...
[18:38:32]  typescript error
            Type ProgressBarComponent in C:/Users/SAGAR/Desktop/MyApp/src/components/progress-bar/progress-bar.ts
            is part of the declarations of 2 modules: AppModule in
            C:/Users/SAGAR/Desktop/MyApp/src/app/app.module.ts and ComponentsModule in
            C:/Users/SAGAR/Desktop/MyApp/src/components/components.module.ts! Please consider moving
            ProgressBarComponent in C:/Users/SAGAR/Desktop/MyApp/src/components/progress-bar/progress-bar.ts to a
            higher module that imports AppModule in C:/Users/SAGAR/Desktop/MyApp/src/app/app.module.ts and
            ComponentsModule in C:/Users/SAGAR/Desktop/MyApp/src/components/components.module.ts. You can also
            create a new NgModule that exports and includes ProgressBarComponent in
            C:/Users/SAGAR/Desktop/MyApp/src/components/progress-bar/progress-bar.ts then import that NgModule in
            AppModule in C:/Users/SAGAR/Desktop/MyApp/src/app/app.module.ts and ComponentsModule in
            C:/Users/SAGAR/Desktop/MyApp/src/components/components.module.ts.

Error: The Angular AoT build failed. See the issues above
    at C:\Users\SAGAR\Desktop\MyApp\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:237:55
    at step (C:\Users\SAGAR\Desktop\MyApp\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:32:23)
    at Object.next (C:\Users\SAGAR\Desktop\MyApp\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:13:53)
    at fulfilled (C:\Users\SAGAR\Desktop\MyApp\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:4:58)
    at <anonymous>
[18:38:32]  copy finished in 3.73 s

#2

NVM. I finally figured out the solution by myself. By removing componetModule.ts . :stuck_out_tongue:


#3

Heyy i am facing same error. Can you say how you solved error briefly so that i can solve.

Thanks in advance!!!


#4

See: https://angular.io/guide/styleguide#overall-structural-guidelines