为了账号安全,请及时绑定邮箱和手机立即绑定

如何从 Go HTTP Server 提供 Angular 应用程序?

如何从 Go HTTP Server 提供 Angular 应用程序?

Go
牛魔王的故事 2022-04-26 10:35:45
我正在尝试从用 Go 编写的服务器提供 Angular 应用程序(Angular 8.2.14)。环顾四周,我发现了下面的片段,据说它可以解决问题。func main() {    http.ListenAndServe(":4000", http.FileServer(http.Dir(folderDist)))}其中folderDist是我构建应用程序的目录。在我的示例中导航到 localhost:4000 时,我在浏览器上收到以下错误:runtime-es2015.js:1 Failed to load module script: The server responded with a non-JavaScript MIME type of "text/plain". Strict MIME type checking is enforced for module scripts per HTML spec.styles-es2015.js:1 Failed to load module script: The server responded with a non-JavaScript MIME type of "text/plain". Strict MIME type checking is enforced for module scripts per HTML spec.main-es2015.js:1 Failed to load module script: The server responded with a non-JavaScript MIME type of "text/plain". Strict MIME type checking is enforced for module scripts per HTML spec.polyfills-es2015.js:1 Failed to load module script: The server responded with a non-JavaScript MIME type of "text/plain". Strict MIME type checking is enforced for module scripts per HTML spec.vendor-es2015.js:1 Failed to load module script: The server responded with a non-JavaScript MIME type of "text/plain". Strict MIME type checking is enforced for module scripts per HTML spec.我错过了什么?我已经尝试过这里建议的解决方案,但错误仍然相同。
查看完整描述

1 回答

?
DIEA

TA贡献1820条经验 获得超3个赞

解决了。

显然,Angular 8 的某些版本中存在错误...

编辑tsconfig.json文件并将“target”行更改为“es5”。

"target": "es5",

制作“ng build”。

完毕!


查看完整回答
反对 回复 2022-04-26
  • 1 回答
  • 0 关注
  • 200 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号