亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何從 Go HTTP Server 為 Angular 應用程序提供服務?

如何從 Go HTTP Server 為 Angular 應用程序提供服務?

Go
蕪湖不蕪 2023-08-14 14:52:28
我正在嘗試從用 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 回答

?
ABOUTYOU

TA貢獻1812條經驗 獲得超5個贊

解決了。

顯然 Angular 8 的某些版本存在錯誤......

編輯tsconfig.json文件并將“target”行更改為“es5”。

"target": "es5",

進行“構建”。

完畢!


查看完整回答
反對 回復 2023-08-14
  • 1 回答
  • 0 關注
  • 163 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號