Search code examples
javascriptandroidangularcordovamime

Server responds with a non-JavaScript MIME type of ""


I want to wrap an angular application with cordova. After hitting "cordova run android" and inspecting it in Chrome, the console states:

"Failed to load module script: The server responded with a non-JavaScript MIME type of "". Strict MIME type checking is enforced for module scripts per HTML spec."

On my phone I obviously only get a white screen then. How can I solve this issue?

When i hit "cordova serve" and look at it in the browser on my PC, there are no errors thrown and everything works fine.

Thank you in advance.

MIME type of ""


Solution

  • I could figure it out, even if it is not a great solution I guess and there might be something nicer.

    After running ng build --prod --aot I went into my index.html and put type="text/javascript" into the <script> tags.

    So basically from

    <script src="runtime-es2015.858f8dd898b75fe86926.js" type="module">

    to

    <script type="text/javascript" src="runtime-es2015.858f8dd898b75fe86926.js" type="module">

    After that I got no more errors.