Error: Cannot find module "." thrown when running --prod

#1

ionic cordova run android --prod

gives the following error after the splash screen. it works without error if --prod flag is absent


Error: Cannot find module "."
    at file:///android_asset/www/build/vendor.js:1:910213
    at file:///android_asset/www/build/vendor.js:1:910283
    at Object.<anonymous> (file:///android_asset/www/build/vendor.js:1:910435)
    at e (file:///android_asset/www/build/vendor.js:1:101)
    at Object.<anonymous> (file:///android_asset/www/build/main.js:1:178389)
    at e (file:///android_asset/www/build/vendor.js:1:101)
    at window.webpackJsonp (file:///android_asset/www/build/vendor.js:1:416)
    at file:///android_asset/www/build/main.js:1:1
Ionic Native: deviceready event fired after 199 ms

Package.json

  "dependencies": {
    "@angular/common": "^5.2.9",
    "@angular/compiler": "^5.2.9",
    "@angular/compiler-cli": "^5.2.9",
    "@angular/core": "^5.2.9",
    "@angular/forms": "^5.2.9",
    "@angular/http": "^5.2.9",
    "@angular/platform-browser": "^5.2.9",
    "@angular/platform-browser-dynamic": "^5.2.9",
    "@ionic-native/android-permissions": "^4.7.0",
    "@ionic-native/background-mode": "^4.9.0",
    "@ionic-native/camera": "^4.7.0",
    "@ionic-native/core": "4.6.0",
    "@ionic-native/diagnostic": "^4.7.0",
    "@ionic-native/local-notifications": "^4.9.0",
    "@ionic-native/network": "^4.9.0",
    "@ionic-native/push": "^4.7.0",
    "@ionic-native/splash-screen": "^4.6.0",
    "@ionic-native/sqlite": "^4.9.1",
    "@ionic-native/status-bar": "^4.6.0",
    "@ionic/storage": "^2.1.3",
    "angular2-jwt": "^0.2.3",
    "angular2-uuid": "^1.1.1",
    "child_process": "^1.0.2",
    "cordova-android": "~6.4.0",
    "cordova-custom-config": "^5.0.2",
    "cordova-ios": "~4.5.4",
    "cordova-plugin-android-permissions": "^1.0.0",
    "cordova-plugin-background-mode": "^0.7.2",
    "cordova-plugin-badge": "^0.8.7",
    "cordova-plugin-camera": "^2.4.1",
    "cordova-plugin-compat": "^1.2.0",
    "cordova-plugin-device": "2.0.2",
    "cordova-plugin-ionic-webview": "1.1.19",
    "cordova-plugin-local-notification": "^0.9.0-beta.2",
    "cordova-plugin-network-information": "^2.0.1",
    "cordova-plugin-splashscreen": "5.0.2",
    "cordova-plugin-whitelist": "1.3.3",
    "cordova-sqlite-storage": "^2.3.3",
    "cordova.plugins.diagnostic": "~3.6.8",
    "crypto-js": "^3.1.9-1",
    "google-libphonenumber": "^3.0.0",
    "ionic-angular": "^3.3.0",
    "ionicons": "^3.0.0",
    "ngx-bootstrap": "^1.8.1",
    "ngx-intl-tel-input": "^1.0.6",
    "openvidu-browser": "^1.9.0",
    "phonegap-plugin-push": "^1.11.1",
    "promise-tool": "^1.1.5",
    "raven-js": "^3.26.2",
    "rxjs": "^5.1.1",
    "sha1": "^1.1.1",
    "sw-toolbox": "^3.6.0",
    "zone.js": "^0.8.14"
  },
  "devDependencies": {
    "@angular/cli": "^1.7.4",
    "@angular/router": "^5.2.10",
    "@ionic/app-scripts": "^3.1.9",
    "@types/crypto-js": "^3.1.33",
    "@types/jasmine": "^2.5.52",
    "@types/kurento-utils": "^6.6.0",
    "@types/node": "^8.0.0",
    "codecov": "^2.2.0",
    "connect": "^3.6.2",
    "ionic": "3.20.0",
    "ionic-mocks": "^0.11.2",
    "jasmine-core": "^2.6.4",
    "jasmine-spec-reporter": "^4.1.1",
    "karma": "^1.7.0",
    "karma-chrome-launcher": "^2.1.1",
    "karma-jasmine": "^1.1.0",
    "karma-mocha-reporter": "^2.2.3",
    "karma-remap-istanbul": "^0.6.0",
    "node-sass": "^4.5.3",
    "protractor": "^5.1.2",
    "serve-static": "^1.12.3",
    "ts-node": "^3.1.0",
    "tslint": "^5.4.3",
    "tslint-eslint-rules": "^4.1.1",
    "typescript": "^2.3.3",
    "webpack": "^3.11.0"
  },
  "description": "An Ionic project",
  "cordova": {
    "plugins": {
      "cordova.plugins.diagnostic": {},
      "cordova-plugin-android-permissions": {},
      "cordova-plugin-whitelist": {},
      "cordova-plugin-device": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-ionic-webview": {},
      "cordova-plugin-camera": {},
      "cordova-custom-config": {},
      "phonegap-plugin-push": {
        "SENDER_ID": "XXXXXXXXXXXX"
      },
      "cordova-plugin-local-notification": {},
      "cordova-plugin-background-mode": {},
      "cordova-plugin-network-information": {},
      "cordova-sqlite-storage": {}
    },
    "platforms": [
      "android",
      "ios"
    ]
  }

app.module.ts

@NgModule({
  declarations: [
    SchoolBellChatApp,
    HomePage
  ],
  imports: [
    CommonModule,
    HttpModule,
    BrowserModule,
    IonicModule.forRoot(SchoolBellChatApp),
    IonicStorageModule.forRoot({
      name: 'sbchat',
      driverOrder: ['indexeddb', 'sqlite', 'websql']
    }),
    AboutUsPageModule,
    ChangePasswordPageModule,
    ChildDetailsPageModule,
    EditProfilePageModule,
    ForgotPasswordPageModule,
    GroupDetailsPageModule,
    IncomminCallPageModule,
    LoginPageModule,
    LogoutPageModule,
    ParentDetailsPageModule,
    PrivacypolicyPageModule,
    RegisterPageModule,
    TandcPageModule,
    TokenVerificationPageModule,
    VideoCallPageModule,
    MenuComponentModule
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    SchoolBellChatApp,
    RegisterPage,
    HomePage,
    LoginPage,
    TandcPage,
    PrivacypolicyPage,
    TokenVerificationPage,
    ForgotPasswordPage,
    ChildDetailsPage,
    GroupDetailsPage,
    ParentDetailsPage,
    VideoCallPage,
    IncomminCallPage,
    EditProfilePage,
    ChangePasswordPage,
    AboutUsPage,
    LogoutPage
  ],
  providers: [
    StatusBar,
    SplashScreen,
    {provide: ErrorHandler, useClass: IonicErrorHandler},
    UserServiceProvider,
    E2eTestingProvider,
    EmailDuplicateValidator,
    DuplicatePhoneValidator,
    StorageServiceProvider,
    AuthenticationServiceProvider,
    ActionSheetProvider,
    Diagnostic,
    AndroidPermissions,
    Push,
    CallServiceProvider,
    ChatServiceProvider,
    BackgroundMode,
    LocalNotifications,
    Network,
    NetworkMonitorProvider,
    SQLite,
    DbServiceProvider
  ]
})
export class AppModule {}

I am clueless any help will be appretiated.

#2

I was able to solve this issue using the link (click here).

Once this is done.

  1. delete npm_modules
  2. run npm install
  3. run yarn

Thanks

1 Like