Ionic cordova build --prod problems


#1

Hi, I’m usingthis library to implement a soap client and works like a charm.

I’m using the library into a ionic lazy loaded project and if i build the project on debug mode it builds correctly with

ionic cordova build android

But if i build the proyect with the --prod mode with

ionic cordova build android --prod

I’m getting this error:


[13:34:12]  build prod started ...
[13:34:12]  clean started ...
[13:34:12]  clean finished in 4 ms
[13:34:12]  copy started ...
[13:34:12]  ngc started ...
[13:34:30]  ngc finished in 18.56 s
[13:34:30]  preprocess started ...
[13:34:30]  deeplinks started ...
[13:34:31]  deeplinks finished in 963 ms
[13:34:31]  optimization started ...
[13:34:32]  copy finished in 19.98 s
[WARN] Error occurred during command execution from a CLI plugin (@ionic/cli-plugin-cordova). Your plugins may be out of
       date.
Error: ./src/app/app.module.ngfactory.js
Module not found: Error: Can't resolve 'ngx-soap/src/ngx-soap.module' in '/Users/user/ionic/Frontend/folder/folder/src/app'
resolve 'ngx-soap/src/ngx-soap.module' in '/Users/user/ionic/Frontend/folder/folder/src/app'
  Parsed request is a module
  using description file: /Users/user/ionic/Frontend/folder/folder/package.json (relative path: ./src/app)
    Field 'browser' doesn't contain a valid alias configuration
  after using description file: /Users/user/ionic/Frontend/folder/folder/package.json (relative path: ./src/app)
    resolve as module
      /Users/user/ionic/Frontend/folder/folder/src/app/node_modules doesn't exist or is not a directory
      /Users/user/ionic/Frontend/folder/folder/src/node_modules doesn't exist or is not a directory
      /Users/user/ionic/Frontend/folder/node_modules doesn't exist or is not a directory
      /Users/user/ionic/Frontend/node_modules doesn't exist or is not a directory
      /Users/user/ionic/node_modules doesn't exist or is not a directory
      /Users/user/node_modules doesn't exist or is not a directory
      /Users/node_modules doesn't exist or is not a directory
      /node_modules doesn't exist or is not a directory
      looking for modules in /Users/user/ionic/Frontend/folder/folder/node_modules
        using description file: /Users/user/ionic/Frontend/folder/folder/package.json (relative path: ./node_modules)
          Field 'browser' doesn't contain a valid alias configuration
        after using description file: /Users/user/ionic/Frontend/folder/folder/package.json (relative path: ./node_modules)
          using description file: /Users/user/ionic/Frontend/folder/folder/node_modules/ngx-soap/package.json (relative path: ./src/ngx-soap.module)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /Users/user/ionic/Frontend/folder/folder/node_modules/ngx-soap/src/ngx-soap.module doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /Users/user/ionic/Frontend/folder/folder/node_modules/ngx-soap/src/ngx-soap.module.js doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              /Users/user/ionic/Frontend/folder/folder/node_modules/ngx-soap/src/ngx-soap.module.ts doesn't exist
            as directory
              /Users/user/ionic/Frontend/folder/folder/node_modules/ngx-soap/src/ngx-soap.module doesn't exist
[/Users/user/ionic/Frontend/folder/folder/src/app/node_modules]
[/Users/user/ionic/Frontend/folder/folder/src/node_modules]
[/Users/user/ionic/Frontend/folder/node_modules]
[/Users/user/ionic/Frontend/node_modules]
[/Users/user/ionic/node_modules]
[/Users/user/node_modules]
[/Users/node_modules]
[/node_modules]
[/Users/user/ionic/Frontend/folder/folder/node_modules/ngx-soap/src/ngx-soap.module]
[/Users/user/ionic/Frontend/folder/folder/node_modules/ngx-soap/src/ngx-soap.module.js]
[/Users/user/ionic/Frontend/folder/folder/node_modules/ngx-soap/src/ngx-soap.module.ts]
[/Users/user/ionic/Frontend/folder/folder/node_modules/ngx-soap/src/ngx-soap.module]
 @ ./src/app/app.module.ngfactory.js 31:0-57
 @ ./src/app/main.ts,./src/app/app.module.ngfactory.js
Module not found: Error: Can't resolve 'ngx-soap/src/soap.service' in '/Users/user/ionic/Frontend/folder/folder/src/app'
resolve 'ngx-soap/src/soap.service' in '/Users/user/ionic/Frontend/folder/folder/src/app'
  Parsed request is a module
  using description file: /Users/user/ionic/Frontend/folder/folder/package.json (relative path: ./src/app)
    Field 'browser' doesn't contain a valid alias configuration
  after using description file: /Users/user/ionic/Frontend/folder/folder/package.json (relative path: ./src/app)
    resolve as module
      /Users/user/ionic/Frontend/folder/folder/src/app/node_modules doesn't exist or is not a directory
      /Users/user/ionic/Frontend/folder/folder/src/node_modules doesn't exist or is not a directory
      /Users/user/ionic/Frontend/folder/node_modules doesn't exist or is not a directory
      /Users/user/ionic/Frontend/node_modules doesn't exist or is not a directory
      /Users/user/ionic/node_modules doesn't exist or is not a directory
      /Users/user/node_modules doesn't exist or is not a directory
      /Users/node_modules doesn't exist or is not a directory
      /node_modules doesn't exist or is not a directory
      looking for modules in /Users/user/ionic/Frontend/folder/folder/node_modules
        using description file: /Users/user/ionic/Frontend/folder/folder/package.json (relative path: ./node_modules)
          Field 'browser' doesn't contain a valid alias configuration
        after using description file: /Users/user/ionic/Frontend/folder/folder/package.json (relative path: ./node_modules)
          using description file: /Users/user/ionic/Frontend/folder/folder/node_modules/ngx-soap/package.json (relative path: ./src/soap.service)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /Users/user/ionic/Frontend/folder/folder/node_modules/ngx-soap/src/soap.service doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /Users/user/ionic/Frontend/folder/folder/node_modules/ngx-soap/src/soap.service.js doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              /Users/user/ionic/Frontend/folder/folder/node_modules/ngx-soap/src/soap.service.ts doesn't exist
            as directory
              /Users/user/ionic/Frontend/folder/folder/node_modules/ngx-soap/src/soap.service doesn't exist
[/Users/user/ionic/Frontend/folder/folder/src/app/node_modules]
[/Users/user/ionic/Frontend/folder/folder/src/node_modules]
[/Users/user/ionic/Frontend/folder/node_modules]
[/Users/user/ionic/Frontend/node_modules]
[/Users/user/ionic/node_modules]
[/Users/user/node_modules]
[/Users/node_modules]
[/node_modules]
[/Users/user/ionic/Frontend/folder/folder/node_modules/ngx-soap/src/soap.service]
[/Users/user/ionic/Frontend/folder/folder/node_modules/ngx-soap/src/soap.service.js]
[/Users/user/ionic/Frontend/folder/folder/node_modules/ngx-soap/src/soap.service.ts]
[/Users/user/ionic/Frontend/folder/folder/node_modules/ngx-soap/src/soap.service]
 @ ./src/app/app.module.ngfactory.js 33:0-54
 @ ./src/app/main.ts,./src/pages/home/home.module.ngfactory.ts
Module not found: Error: Can't resolve 'ngx-soap/src/soap.service' in '/Users/user/ionic/Frontend/folder/folder/src/pages/home'
resolve 'ngx-soap/src/soap.service' in '/Users/user/ionic/Frontend/folder/folder/src/pages/home'
  Parsed request is a module
  using description file: /Users/user/ionic/Frontend/folder/folder/package.json (relative path: ./src/pages/home)
    Field 'browser' doesn't contain a valid alias configuration
  after using description file: /Users/user/ionic/Frontend/folder/folder/package.json (relative path: ./src/pages/home)
    resolve as module
      /Users/user/ionic/Frontend/folder/folder/src/pages/home/node_modules doesn't exist or is not a directory
      /Users/user/ionic/Frontend/folder/folder/src/pages/node_modules doesn't exist or is not a directory
      /Users/user/ionic/Frontend/folder/folder/src/node_modules doesn't exist or is not a directory
      /Users/user/ionic/Frontend/folder/node_modules doesn't exist or is not a directory
      /Users/user/ionic/Frontend/node_modules doesn't exist or is not a directory
      /Users/user/ionic/node_modules doesn't exist or is not a directory
      /Users/user/node_modules doesn't exist or is not a directory
      /Users/node_modules doesn't exist or is not a directory
      /node_modules doesn't exist or is not a directory
      looking for modules in /Users/user/ionic/Frontend/folder/folder/node_modules
        using description file: /Users/user/ionic/Frontend/folder/folder/package.json (relative path: ./node_modules)
          Field 'browser' doesn't contain a valid alias configuration
        after using description file: /Users/user/ionic/Frontend/folder/folder/package.json (relative path: ./node_modules)
          using description file: /Users/user/ionic/Frontend/folder/folder/node_modules/ngx-soap/package.json (relative path: ./src/soap.service)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /Users/user/ionic/Frontend/folder/folder/node_modules/ngx-soap/src/soap.service doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /Users/user/ionic/Frontend/folder/folder/node_modules/ngx-soap/src/soap.service.js doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              /Users/user/ionic/Frontend/folder/folder/node_modules/ngx-soap/src/soap.service.ts doesn't exist
            as directory
              /Users/user/ionic/Frontend/folder/folder/node_modules/ngx-soap/src/soap.service doesn't exist
[/Users/user/ionic/Frontend/folder/folder/src/pages/home/node_modules]
[/Users/user/ionic/Frontend/folder/folder/src/pages/node_modules]
[/Users/user/ionic/Frontend/folder/folder/src/node_modules]
[/Users/user/ionic/Frontend/folder/node_modules]
[/Users/user/ionic/Frontend/node_modules]
[/Users/user/ionic/node_modules]
[/Users/user/node_modules]
[/Users/node_modules]
[/node_modules]
[/Users/user/ionic/Frontend/folder/folder/node_modules/ngx-soap/src/soap.service]
[/Users/user/ionic/Frontend/folder/folder/node_modules/ngx-soap/src/soap.service.js]
[/Users/user/ionic/Frontend/folder/folder/node_modules/ngx-soap/src/soap.service.ts]
[/Users/user/ionic/Frontend/folder/folder/node_modules/ngx-soap/src/soap.service]
 @ ./src/pages/home/home.module.ngfactory.ts 41:0-54
 @ ./src lazy
 @ ./node_modules/ionic-angular/util/ng-module-loader.js
 @ ./src/app/app.module.ngfactory.js
 @ ./src/app/main.ts,./src/pages/login/login.module.ngfactory.ts
Module not found: Error: Can't resolve 'ngx-soap/src/soap.service' in '/Users/user/ionic/Frontend/folder/folder/src/pages/login'
resolve 'ngx-soap/src/soap.service' in '/Users/user/ionic/Frontend/folder/folder/src/pages/login'
  Parsed request is a module
  using description file: /Users/user/ionic/Frontend/folder/folder/package.json (relative path: ./src/pages/login)
    Field 'browser' doesn't contain a valid alias configuration
  after using description file: /Users/user/ionic/Frontend/folder/folder/package.json (relative path: ./src/pages/login)
    resolve as module
      /Users/user/ionic/Frontend/folder/folder/src/pages/login/node_modules doesn't exist or is not a directory
      /Users/user/ionic/Frontend/folder/folder/src/pages/node_modules doesn't exist or is not a directory
      /Users/user/ionic/Frontend/folder/folder/src/node_modules doesn't exist or is not a directory
      /Users/user/ionic/Frontend/folder/node_modules doesn't exist or is not a directory
      /Users/user/ionic/Frontend/node_modules doesn't exist or is not a directory
      /Users/user/ionic/node_modules doesn't exist or is not a directory
      /Users/user/node_modules doesn't exist or is not a directory
      /Users/node_modules doesn't exist or is not a directory
      /node_modules doesn't exist or is not a directory
      looking for modules in /Users/user/ionic/Frontend/folder/folder/node_modules
        using description file: /Users/user/ionic/Frontend/folder/folder/package.json (relative path: ./node_modules)
          Field 'browser' doesn't contain a valid alias configuration
        after using description file: /Users/user/ionic/Frontend/folder/folder/package.json (relative path: ./node_modules)
          using description file: /Users/user/ionic/Frontend/folder/folder/node_modules/ngx-soap/package.json (relative path: ./src/soap.service)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /Users/user/ionic/Frontend/folder/folder/node_modules/ngx-soap/src/soap.service doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /Users/user/ionic/Frontend/folder/folder/node_modules/ngx-soap/src/soap.service.js doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              /Users/user/ionic/Frontend/folder/folder/node_modules/ngx-soap/src/soap.service.ts doesn't exist
            as directory
              /Users/user/ionic/Frontend/folder/folder/node_modules/ngx-soap/src/soap.service doesn't exist
[/Users/user/ionic/Frontend/folder/folder/src/pages/login/node_modules]
[/Users/user/ionic/Frontend/folder/folder/src/pages/node_modules]
[/Users/user/ionic/Frontend/folder/folder/src/node_modules]
[/Users/user/ionic/Frontend/folder/node_modules]
[/Users/user/ionic/Frontend/node_modules]
[/Users/user/ionic/node_modules]
[/Users/user/node_modules]
[/Users/node_modules]
[/node_modules]
[/Users/user/ionic/Frontend/folder/folder/node_modules/ngx-soap/src/soap.service]
[/Users/user/ionic/Frontend/folder/folder/node_modules/ngx-soap/src/soap.service.js]
[/Users/user/ionic/Frontend/folder/folder/node_modules/ngx-soap/src/soap.service.ts]
[/Users/user/ionic/Frontend/folder/folder/node_modules/ngx-soap/src/soap.service]
 @ ./src/pages/login/login.module.ngfactory.ts 43:0-54
 @ ./src lazy
 @ ./node_modules/ionic-angular/util/ng-module-loader.js
 @ ./src/app/app.module.ngfactory.js
 @ ./src/app/main.ts

What would be wrong?

Thanks for all


#2

That is a webpack optimization problem :confused:

Probably something similar to this:
https://github.com/ionic-team/ionic-app-scripts/pull/1153
https://github.com/ionic-team/ionic-app-scripts/issues/1148

What is the actual folder name here? In node_modules? Or your project?


#3

/Users/myname/ionic/Frontend/myfoldername/nameOfProject/package.json

I’ve replaced the original names to show you the error codes.

What would be a posible solution?


#4

Show us your app.modules.ts please.

Solution might be similar to the PR I linked to - but we have to understand the actual problem first. Webpack somehow doesn’t find something, from the error message you posted it sounds like it is trying to include node_modules which makes no sense of course. Maybe some relative import or something…


#5

This is my package.json

{
    "name": "myapp",
    "version": "0.0.1",
    "author": "user",
    "homepage": "http://user.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": "4.1.3",
        "@angular/compiler": "4.1.3",
        "@angular/compiler-cli": "4.1.3",
        "@angular/core": "4.1.3",
        "@angular/forms": "4.1.3",
        "@angular/http": "4.1.3",
        "@angular/platform-browser": "4.1.3",
        "@angular/platform-browser-dynamic": "4.1.3",
        "@ionic-native/core": "3.12.1",
        "@ionic-native/splash-screen": "3.12.1",
        "@ionic-native/status-bar": "3.12.1",
        "@ionic/storage": "2.0.1",
        "@ngx-translate/core": "^7.1.0",
        "@ngx-translate/http-loader": "^0.1.0",
        "cordova-ios": "^4.4.0",
        "cordova-plugin-console": "^1.0.5",
        "cordova-plugin-device": "^1.1.4",
        "cordova-plugin-splashscreen": "^4.0.3",
        "cordova-plugin-statusbar": "^2.2.2",
        "cordova-plugin-whitelist": "^1.3.1",
        "ionic-angular": "3.5.3",
        "ionic-plugin-keyboard": "^2.2.1",
        "ionicons": "3.0.0",
        "localforage": "^1.5.0",
        "rxjs": "5.4.0",
        "sw-toolbox": "3.6.0",
        "zone.js": "0.8.12",
        "ngx-soap": "^0.1.4"
    },
    "devDependencies": {
        "@ionic/app-scripts": "2.0.2",
        "@ionic/cli-plugin-cordova": "1.4.1",
        "@ionic/cli-plugin-ionic-angular": "1.3.2",
        "typescript": "2.3.4"
    },
    "description": "An Ionic project",
    "cordova": {
        "plugins": {
            "cordova-plugin-console": {},
            "cordova-plugin-device": {},
            "cordova-plugin-splashscreen": {},
            "cordova-plugin-statusbar": {},
            "cordova-plugin-whitelist": {},
            "ionic-plugin-keyboard": {}
        },
        "platforms": [
            "ios"
        ]
    }
}

This is my app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';

import { MyApp } from './app.component';

import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import {Http, HttpModule} from "@angular/http";
import {TranslateLoader, TranslateModule} from "@ngx-translate/core";
import {TranslateHttpLoader} from "@ngx-translate/http-loader";
import { NgxSoapModule } from 'ngx-soap';

export function createTranslateLoader(http: Http) {
  return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}

@NgModule({
  declarations: [
    MyApp
  ],
  imports: [
    BrowserModule,
    HttpModule,
    IonicModule.forRoot(MyApp, {
      scrollAssist: false,
      autoFocusAssist: false
    }),
    TranslateModule.forRoot({
      loader: {
        provide: TranslateLoader,
        useFactory: (createTranslateLoader),
        deps: [Http]
      }
    }),
NgxSoapModule
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp
  ],
  providers: [
    StatusBar,
    SplashScreen,
    {provide: ErrorHandler, useClass: IonicErrorHandler}
  ]
})
export class AppModule {}

Thanks


#6

I have no idea…

I think you should create an issue here: https://github.com/ionic-team/ionic-app-scripts/issues
Mention that the optimization step somehow can not handle that library.


#7

With app scripts 1.3.3 works fine…

I’m going to open an issue


#8

Include your ionic info (just noticed I never asked for that here - should have).
Post the link to the issue when you are done please.


#9

this is my ionic info

Your system information:

cli packages:

    @ionic/cli-plugin-cordova       : 1.5.0 
    @ionic/cli-plugin-ionic-angular : 1.4.0 
    @ionic/cli-utils                : 1.6.0 
    ionic (Ionic CLI)               : 3.6.0

global packages:

    Cordova CLI : 6.5.0

local packages:

    @ionic/app-scripts : 2.1.3
    Cordova Platforms  : android 6.1.2
    Ionic Framework    : ionic-angular 3.6.0

System:

    Node : v6.10.1
    OS   : Windows 7
    npm  : 3.10.10

This problem is similar to

This is my opened issue

thanks


#10

Run into the same problem help!? Did you guys fix it