我正在嘗試從用 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”。
完畢!
- 1 回答
- 0 關注
- 155 瀏覽
添加回答
舉報
0/150
提交
取消