【发布时间】:2020-02-14 16:09:41
【问题描述】:
我尝试部署一个 Angular/CLI 6.12.0 项目。
当我将“dist”文件夹内容放在服务器上时,出现控制台错误 “输入 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 »).
这对我来说是法语^^。 你可以在控制台看到它http://biblio.sylvainallain.fr
它是一个像库一样的简单应用程序。 后端(日志和数据)由 Firebase 管理。
在本地,一切正常。
我使用“ng build --prod”进行构建,它会创建一个“dist”文件夹。
prod 后我的 index.html:
<!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>
我发现这个 GitHub 帖子:https://github.com/angular/angular-cli/issues/10325 .这是同样的问题,我尝试了一些解决方案,但没有任何效果。
问题仅在于 es2015.*.js 文件。所以我认为type="module" 存在一个问题,它不像 Javascript 文件那样被识别。
我不明白为什么 Angular 不管理它。
编辑 10 月 25 日:
尝试将
type="module"替换为type="application/javascript"。不要工作。 Source尝试再次使用
ng update @angular/cli @angular/core --allow-dirty和ng build --prod更新 Angular/CLI 和 Angular/core。不工作尝试使用 Firebase 托管它。同样的问题:https://bibliang.firebaseapp.com/
感谢您的帮助! :)
【问题讨论】:
标签: javascript angular deployment build mime-types