0
votes

I have developed one app in Ionic and while I try to deploy my app with --prod its throwing below error and without --prod its working fine.

Command : sudo ionic cordova build ios --release --prod

Error :

Error: ./src/app/main.ts

Module not found: Error: Can't resolve './app.module.ngfactory' in '/Volumes/DATA/Dhanesh/Projects/FA app/TestNewCordova/failure_analysis_app/Ionic/src/app' resolve './app.module.ngfactory' in '/Volumes/DATA/Dhanesh/Projects/FA app/TestNewCordova/failure_analysis_app/Ionic/src/app' using description file: /Volumes/DATA/Dhanesh/Projects/FA app/TestNewCordova/failure_analysis_app/Ionic/package.json (relative path: ./src/app) Field 'browser' doesn't contain a valid alias configuration after using description file: /Volumes/DATA/Dhanesh/Projects/FA app/TestNewCordova/failure_analysis_app/Ionic/package.json (relative path: ./src/app) using description file: /Volumes/DATA/Dhanesh/Projects/FA app/TestNewCordova/failure_analysis_app/Ionic/package.json (relative path: ./src/app/app.module.ngfactory) no extension

While if I remove --prod and just run sudo ionic cordova build ios --release

and without fail it build successfully.

I found many solution for above error but still didn't got any luck to come out from this error.

Ref I tried so far :

  1. Try to find error in $ ./node_modules/.bin/ngc but there is no error log over there.

  2. Some post on github also not working https://github.com/angular/angular-cli/issues/8858

Help me if nay one solved same problem with ionic build ios.

Thanks in advance!

Edit :

main.ts

import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

import { AppModule } from './app.module';
import { enableProdMode } from '@angular/core'; 

enableProdMode();

platformBrowserDynamic().bootstrapModule(AppModule);
1
I also faced this problem. Can i know what is your ionic/app-script version and also what version of angular you are using - Abinesh Joyel
from where I can find this version can you please guide me ? - CodeChanger
from root folder there will be package.json file. just copy and paste that file - Abinesh Joyel
Ok got it here is my ionic script version : "@ionic/app-scripts": "3.1.2" - CodeChanger
ok just upgrade the ionic app script using npm install @ionic/app-scripts@latest --save-dev and check once again run build using --prod flag and make sure that angular is in production mode in main.ts file - Abinesh Joyel

1 Answers

1
votes

Just upgrade the ionic app script using npm install @ionic/app-scripts@latest --save-dev and check once again run build using --prod flag