Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 8 ng-build throwing MIME error with cordova

While executing ng build --prod --base-href ./ for building my cordova app, the final output throws an error as below.

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.

I did end up fixing this by changing type module to text/javascript

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

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

Is there something that can be done within angular.json file to fix or am I missing out something here?

like image 791
Nidhin Joseph Avatar asked Jun 15 '19 01:06

Nidhin Joseph


1 Answers

I had the same issue.

  1. Created a new project.
  2. Built a production version

      "build-production": "ng build --configuration=production --extract-css=false --prod --aot" 
  3. Deployed to NGINX

  4. White page with no content between tags in Chrome Element inspector

Fix

Update tsconfig.json

        "target": "es5", 

Then rebuild the application and deploy again.

This solution worked for me, I now have content in my deployed app.

Hope it helps somebody

like image 71
englishPete Avatar answered Oct 24 '22 11:10

englishPete