1

I am importing Ionic into my index.html with this:

<script type="module" src="ionic/ionic/ionic.esm.js"></script>
<script nomodule="" src="ionic/ionic/ionic.js"></script>

On Browser and iOS and even Android Emulator everything works fine. Only on Android Devices I get Failed to load module script: The server responded with a non-JavaScript MIME type of "".

I found one or two questions on SO and issues on GitHub, but no simple solution to my problem..

How can I resolve the error?

Josh
  • 504
  • 3
  • 14

1 Answers1

3

If you are loading from file protocol (default by cordova) you can’t use modules.

You can use cordova-plugin-ionic-webview, it loads from http or https and modules will work.

jcesarmobile
  • 51,328
  • 11
  • 132
  • 176
  • Thank you, worked like a charm! It is enough to just add the plugin, no? – Josh Dec 07 '19 at 10:01
  • 1
    Yes, that’s enough – jcesarmobile Dec 07 '19 at 10:28
  • 1
    here it says it's because file protocol doesn't provide any mime and modules need to know the mime https://stackoverflow.com/questions/47403478/es6-modules-in-local-files-the-server-responded-with-a-non-javascript-mime-typ but I don't know any official documentation – jcesarmobile Dec 07 '19 at 11:11