部署Angular Project错误类型MIME(text/html) [英] Deployment Angular Project error type MIME (text/html)
问题描述
我尝试部署Angular/CLI 6.12.0项目.
I try to deploy an Angular/CLI 6.12.0 project.
当我在服务器上放置"dist"文件夹内容时,出现控制台错误 "MIME类型".
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 »).
这对我来说是法语^^. 您可以在控制台中查看它 http://biblio.sylvainallain.fr
This in French for me ^^. You can see it in console here http://biblio.sylvainallain.fr
这是一个像库这样的简单应用程序. 后端(日志和数据)通过Firebase进行管理.
It's a simply application like a library. Back-end (logs and data) is manage with Firebase.
在本地,一切正常.
我使用"ng build --prod"进行构建,它创建了一个"dist"文件夹.
I make the build with "ng build --prod", it create a "dist" folder.
生产后的我的index.html:
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>
我找到此GitHub帖子: https://github.com/angular/angular -cli/issues/10325 .这是相同的问题,我尝试了一些解决方案,但没有任何效果.
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.
此问题仅与es2015.*.js
文件有关.因此,我认为type="module"
存在一个无法像Javascript文件那样识别的问题.
我不明白为什么Angular不管理它.
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.
修改:10月25日:
-
尝试将
type="module"
替换为type="application/javascript"
.不要工作来源
尝试更新Angular/CLI&再次使用ng update @angular/cli @angular/core --allow-dirty
和ng build --prod
的角度/核心.不工作
try to update Angular/CLI & Angular/core with ng update @angular/cli @angular/core --allow-dirty
and ng build --prod
again. Don't work
尝试使用Firebase托管它.相同的问题: https://bibliang.firebaseapp.com/
try to host it with Firebase. Same issue: https://bibliang.firebaseapp.com/
感谢您的帮助! :)
推荐答案
<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>
keep all above file in another folder and give path here like
<script src="../../js/polyfills-es2015.fd917e7c3ed57f282ee5.js" type="text/javascript"></script>
它将起作用
这篇关于部署Angular Project错误类型MIME(text/html)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!