Field 'browser' doesn't contain a valid alias configuration ./app.module.ngfactory package.json ionic cordova build android --prod

Any ideas what’s wrong? How can I solve it?
WIthout prod runs fine , all the ways…


PS C:\Users\2bher\WebstormProjects\wiseapp\wiseapp> ionic cordova build  android --prod
Running app-scripts build: --prod --platform android --target cordova
[20:07:18]  build prod started ...
[20:07:18]  clean started ...
[20:07:18]  clean finished in 4 ms
[20:07:18]  copy started ...
[20:07:18]  deeplinks started ...
[20:07:18]  deeplinks finished in 290 ms
[20:07:18]  ngc started ...
[20:07:27]  ngc finished in 9.13 s
[20:07:27]  preprocess started ...
[20:07:27]  preprocess finished in 16 ms
[20:07:27]  webpack started ...
[20:07:28]  copy finished in 9.75 s
Error: ./src/app/main.ts
Module not found: Error: Can't resolve './app.module.ngfactory' in 'C:\Users\2bher\WebstormProjects\wiseapp\wiseapp\src\app'
resolve './app.module.ngfactory' in 'C:\Users\2bher\WebstormProjects\wiseapp\wiseapp\src\app'
  using description file: C:\Users\2bher\WebstormProjects\wiseapp\wiseapp\package.json (relative path:
./src/app)
    Field 'browser' doesn't contain a valid alias configuration
  after using description file: C:\Users\2bher\WebstormProjects\wiseapp\wiseapp\package.json (relative
path: ./src/app)
    using description file: C:\Users\2bher\WebstormProjects\wiseapp\wiseapp\package.json (relative path: ./src/app/app.module.ngfactory)
      no extension
        Field 'browser' doesn't contain a valid alias configuration
        C:\Users\2bher\WebstormProjects\wiseapp\wiseapp\src\app\app.module.ngfactory doesn't exist
      .ts
        Field 'browser' doesn't contain a valid alias configuration
        C:\Users\2bher\WebstormProjects\wiseapp\wiseapp\src\app\app.module.ngfactory.ts doesn't exist
      .js
        Field 'browser' doesn't contain a valid alias configuration
        C:\Users\2bher\WebstormProjects\wiseapp\wiseapp\src\app\app.module.ngfactory.js doesn't exist
      .json
        Field 'browser' doesn't contain a valid alias configuration
        C:\Users\2bher\WebstormProjects\wiseapp\wiseapp\src\app\app.module.ngfactory.json doesn't exist      as directory
        C:\Users\2bher\WebstormProjects\wiseapp\wiseapp\src\app\app.module.ngfactory doesn't exist
[C:\Users\2bher\WebstormProjects\wiseapp\wiseapp\src\app\app.module.ngfactory]
[C:\Users\2bher\WebstormProjects\wiseapp\wiseapp\src\app\app.module.ngfactory.ts]
[C:\Users\2bher\WebstormProjects\wiseapp\wiseapp\src\app\app.module.ngfactory.js]
[C:\Users\2bher\WebstormProjects\wiseapp\wiseapp\src\app\app.module.ngfactory.json]
[C:\Users\2bher\WebstormProjects\wiseapp\wiseapp\src\app\app.module.ngfactory]
 @ ./src/app/main.ts 2:0-60
    at new BuildError (C:\Users\2bher\WebstormProjects\wiseapp\wiseapp\node_modules\@ionic\app-scripts\dist\util\errors.js:16:28)

er.js:269:13)
    at Compiler.emitRecords (C:\Users\2bher\WebstormProjects\wiseapp\wiseapp\node_modules\webpack\lib\Compiler.js:375:38)    at emitAssets.err (C:\Users\2bher\WebstormProjects\wiseapp\wiseapp\node_modules\webpack\lib\Compiler.js:262:10)
    at applyPluginsAsyncSeries1.err (C:\Users\2bher\WebstormProjects\wiseapp\wiseapp\node_modules\webpack\lib\Compiler.js:368:12)    at next (C:\Users\2bher\WebstormProjects\wiseapp\wiseapp\node_modules\tapable\lib\Tapable.js:218:11)
    at Compiler.compiler.plugin (C:\Users\2bher\WebstormProjects\wiseapp\wiseapp\node_modules\webpack\lib\performance\SizeLimitsPlugin.js:99:4)
    at Compiler.applyPluginsAsyncSeries1 (C:\Users\2bher\WebstormProjects\wiseapp\wiseapp\node_modules\tapable\lib\Tapable.js:222:13)    at Compiler.afterEmit (C:\Users\2bher\WebstormProjects\wiseapp\wiseapp\node_modules\webpack\lib\Compiler.js:365:9)

{

  "name": "wiseapp",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "private": true,
  "scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "lint": "ionic-app-scripts lint",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "dependencies": {
    "@angular/common": "5.0.1",
    "@angular/compiler": "5.0.1",
    "@angular/compiler-cli": "5.0.1",
    "@angular/core": "5.0.1",
    "@angular/forms": "5.0.1",
    "@angular/http": "5.0.1",
    "@angular/platform-browser": "5.0.1",
    "@angular/platform-browser-dynamic": "5.0.1",
    "@ionic-native/camera": "^4.4.2",
    "@ionic-native/core": "4.4.0",
    "@ionic-native/geolocation": "^4.4.2",
    "@ionic-native/google-maps": "^4.4.2",
    "@ionic-native/network": "^4.4.2",
    "@ionic-native/splash-screen": "4.4.0",
    "@ionic-native/status-bar": "4.4.0",
    "@ionic/pro": "1.0.16",
    "@ionic/storage": "2.1.3",
    "@ngx-translate/core": "^8.0.0",
    "@ngx-translate/http-loader": "^2.0.0",
    "chart.js": "^2.7.1",
    "cordova-android": "6.3.0",
    "cordova-browser": "5.0.1",
    "cordova-plugin-camera": "^3.0.0",
    "cordova-plugin-device": "^1.1.4",
    "cordova-plugin-facebook4": "^1.9.1",
    "cordova-plugin-geolocation": "^3.0.0",
    "cordova-plugin-googlemaps": "^2.1.1",
    "cordova-plugin-ionic-webview": "^1.1.16",
    "cordova-plugin-network-information": "^1.3.4",
    "cordova-plugin-splashscreen": "^4.0.3",
    "cordova-plugin-statusbar": "^2.3.0",
    "cordova-plugin-whitelist": "^1.3.1",
    "font-awesome": "^4.7.0",
    "ionic-angular": "3.9.2",
    "ionic-native": "^2.9.0",
    "ionic-plugin-keyboard": "^2.2.1",
    "ionicons": "3.0.0",
    "rxjs": "5.5.2",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.18"
  },
  "devDependencies": {
    "@ionic/app-scripts": "3.1.2",
    "typescript": "2.4.2"
  },
  "description": "An Ionic project",
  "cordova": {
    "plugins": {
      "cordova-plugin-geolocation": {
        "GEOLOCATION_USAGE_DESCRIPTION": "Wiseapp customer loaction"
      },
      "cordova-plugin-network-information": {},
      "cordova-plugin-camera": {},
      "ionic-plugin-keyboard": {},
      "cordova-plugin-whitelist": {},
      "cordova-plugin-device": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-ionic-webview": {},
      "cordova-plugin-googlemaps": {
        "API_KEY_FOR_ANDROID": "AIzaSyAa3AAitzhvZ6rHHGkvZwO-v6gHzRiNung",
        "API_KEY_FOR_IOS": "AIzaSyC9Q0pSTFtoK0kQ0yKrnSTrKAH9vylAoqs"
      },
      "cordova-plugin-statusbar": {},
      "cordova-plugin-facebook4": {
        "APP_ID": "150689565500190",
        "APP_NAME": "com.wiseapp.wiseapp"
      }
    },
    "platforms": [
      "android",
      "browser"
    ]
  },
  "config": {
    "ionic_bundler": "webpack",
    "ionic_source_map": "source-map",
    "ionic_copy": "./scripts/copy-custom-libs.js"
  }
}

same problem after update to 3.19 cli

Do you have any aliases configured in tsconfig.json ?

    "baseUrl": "./src",
    "paths": {
      "@app/*": [ "app/*" ],
      "@assets/*": [ "assets/*" ],
      "@env": [ "environments/environment" ],
      "@pages/*": [ "pages/*" ],
      "@services/*": [ "services/*" ],
      "@theme/*": [ "theme/*" ]
    }

Try running ./node_modules/.bin/ngc to see if it gives you a more useful error message. I’m currently dealing with a problem with the angular-svg-round-progressbar package which doesn’t support AOT properly. The error message I see when running ionic cordova build android --prod looks almost exactly like yours, whereas ./node_modules/.bin/ngc gives:

Error: Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function (position 194:50 in the original .ts file), resolving symbol NgModule in /Users/kramme/ionic/my-app-name/node_modules/angular-svg-round-progressbar/node_modules/@angular/core/core.d.ts, resolving symbol RoundProgressModule in /Users/kramme/ionic/my-app-name/node_modules/angular-svg-round-progressbar/dist/index.d.ts, resolving symbol RoundProgressModule in /Users/kramme/ionic/my-app-name/node_modules/angular-svg-round-progressbar/dist/index.d.ts

By removing the angular-svg-round-progressbar package, I’ve been able to confirm that it was causing my issue. You might have be facing a similar one.

This closed issue helped me alot: https://github.com/ionic-team/ionic/issues/13356 I forgot to remove one directive’s import that not exists in app.module.ts

My solution was to downgrade to angular 5.0.0 and upgrade typescript to 2.6.1

Module not found: Error: Can’t resolve ‘./app.module.ngfactory’ ionic-angular 3.9.0

Here are the general instructions that were sent around to testers and some early adopters that we asked to test out the next release:
1. Blow away node_modules and package-lock.json
2. Set Typescript to ~2.4.2
3. Set Angular to 5.0.0
4. Set @ionic/app-scripts to nightly
5. Set ionic-angular to nightly
6. Set @ionic/storage to 2.1.3
7. Set rxjs to 5.5.2
8. Run npm install

From https://github.com/ionic-team/ionic/issues/13356

ionic cordova resources

From https://ionicframework.com/docs/cli/cordova/resources/

Error: ./node_modules/rxjs/observable/BoundNodeCallbackObservable.js
Module build failed: TypeError: Cannot read property ‘type’ of undefined

To disable this warning run “ng set --global warnings.typescriptMismatch=false”.

From https://github.com/angular/angular/issues/20095

Upgrading typescript to “typescript”: “~2.6.1” solve the problem

From https://github.com/ionic-team/ionic-cli/issues/2873

Runs well - apk 5mb instead of 10 mb
ionic cordova build android --prod --build-optimizer --release --aot

How do you run the command of ngc?