Angular Universal 15.1.0本地i18n运行报错:无法加载模块脚本
Angular Universal 15.1.0 本地启用i18n时MIME类型错误排查
我尝试让Angular Universal应用(版本15.1.0)在本地启用i18n运行,但持续出现以下错误:
Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.
该错误针对所有JS文件抛出:
- runtime.js
- vendor.js
- polyfills.js
- main.js
我怀疑是baseHref属性配置错误,其他相关帖子也指向这个方向,但始终找不到问题所在。
以下是我的angular.json文件的相关配置(应用名为"public"):
projects > public 的i18n配置
"i18n": { "sourceLocale": "en-US", "locales": { "de-DE": { "translation": "src/locale/messages.de.xlf", "baseHref": "/" } } },
projects > public > architect > build 的配置
"options": { "baseHref": "/", "localize": true, "outputPath": "dist/public/browser", "index": "src/index.html", "main": "src/main.ts", "polyfills": "src/polyfills.ts", "tsConfig": "tsconfig.app.json", "assets": [ "src/favicon.ico", "src/assets" ], "styles": ["src/styles.scss"], "scripts": [], "vendorChunk": true, "extractLicenses": false, "buildOptimizer": false, "sourceMap": true, "optimization": false, "namedChunks": true },
我也曾尝试将所有baseHref属性替换为空字符串,但仍未解决问题。我的默认语言为en-US,另一种语言为de-DE,当前正尝试在本地运行en-US版本。
我忽略了什么?
内容的提问来源于stack exchange,提问作者user3255061
相关产品推荐
相关产品推荐

