Deployment Angular Project error type MIME (text/html)

假如想象 提交于 2020-01-03 05:28:07

问题


I try to deploy an Angular/CLI 6.12.0 project.

When I put "dist" folder content on a server, there is a console error "type MIME".

Le chargement du module à l’adresse « http://www.sylvainallain.fr/polyfills-es2015.fd917e7c3ed57f282ee5.js » a été bloqué en raison d’un type MIME interdit (« text/html »).
Le chargement du module à l’adresse « http://www.sylvainallain.fr/main-es2015.2fcd6517edb1de962f8a.js » a été bloqué en raison d’un type MIME interdit (« text/html »).
Le chargement du module à l’adresse « http://www.sylvainallain.fr/runtime-es2015.24b02acc1f369d9b9f37.js » a été bloqué en raison d’un type MIME interdit (« text/html »).

https://imgur.com/fQKnWAg.jpg

This in French for me ^^. You can see it in console here http://biblio.sylvainallain.fr

It's a simply application like a library. Back-end (logs and data) is manage with Firebase.

In local, all is OK.

I make the build with "ng build --prod", it create a "dist" folder.

My index.html after prod:

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Bibliothèque Angular</title>
  <base href="/">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="stylesheet" href="styles.735ba4029395bfd97371.css"></head>
<body>
  <app-root></app-root>
    <script src="polyfills-es5.f9fad3ad3c84e6dbdd72.js" nomodule defer></script>
    <script src="polyfills-es2015.fd917e7c3ed57f282ee5.js" type="module"></script>
    <script src="runtime-es2015.24b02acc1f369d9b9f37.js" type="module"></script>
    <script src="main-es2015.2fcd6517edb1de962f8a.js" type="module"></script>
    <script src="runtime-es5.24b02acc1f369d9b9f37.js" nomodule defer></script>
    <script src="main-es5.2fcd6517edb1de962f8a.js" nomodule defer></script></body>
</html>

I find this GitHub post: https://github.com/angular/angular-cli/issues/10325 .This is the same issue, I try some solutions but nothing work.

The issue is only with es2015.*.js files. So I think there is an issue with type="module" which is not recognize like a Javascript file. I don't understand why Angular don't manage it.

Edit 25 October :

  • try to replace type="module" with type="application/javascript". Don't work. Source

  • try to update Angular/CLI & Angular/core with ng update @angular/cli @angular/core --allow-dirty and ng build --prod again. Don't work

  • try to host it with Firebase. Same issue: https://bibliang.firebaseapp.com/

Thanks for help ! :)

来源:https://stackoverflow.com/questions/58437681/deployment-angular-project-error-type-mime-text-html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!