Search code examples
angularcordovaionic-frameworkproduction-environmentmultiplatform

Cannot find module “.” when building prod release


I am developing an Ionic4 application with Angular4 as core.

This time I don't need a help with programming (through might not be the best), but I need to create production package that can be used (at least) on the Google Play store.

Application runs fine on the phone run with:

ionic cordova run android --device -lsc

and simply in the browser with:

ionic serve

but when I do a production build either for browser or android platform with:

ionic cordova run browser --release --prod

or

ionic cordova build android --release --prod

I get:

Uncaught Error: Cannot find module "."
    at vendor.js:1
    at vendor.js:1
    at Object.<anonymous> (vendor.js:1)
    at i (vendor.js:1)
    at Object.557 (main.js:1)
    at i (vendor.js:1)
    at window.webpackJsonp (vendor.js:1)
    at main.js:1

One doesn't know much from this output. That's because implicit minify and uglify, which I can not turn off to see what is happening and as I said when running non-prod everything works fine.

I have read thread about *-umd imports causing this, but I don't use them.

So basically my question is how to fix this?

I have pushed my project to the git for anyone willing to help cause I am being really desperate and so much behind the schedule.

Any kind of help much appreciated!

EDIT: I should have told, you don't need any backend to get this error. It pops right after app loads.


Solution

  • so, I got this resolved however I cannot really tell the real cause.

    I can give you some steps for making some analysis and find out what is going on through.

    1. Install ionic-app-scripts globally and build project ionic-app-scripts build
    2. cordova run browser

    This should point you out some previously not seen errors. Than, I found out that you can't have NavController injected at the root page because it doesn't exist yet. reference.

    I also found out that I had some services injected twice.

    Then, I suggest you to comment out all modules and providers and cativate it one-by-one with it's dependencies.

    That way prod release has succeeded for me.