使用简单的 Angular 应用程序部署到 Firebase 托管失败

Deployment fails to Firebase Hosting with simple Angular App

我开发了一个非常简单的 angular 应用程序(只显示主页,并尝试部署到 Firebase 托管,如有关该主题的几个视频所示。当我运行 它在本地使用 ng serve,我从 firebase deploy 得到如下输出:

i  deploying hosting
i  hosting[bkc-22519]: beginning deploy...
i  hosting[bkc-22519]: found 10 files in dist/hosting-test
✔  hosting[bkc-22519]: file upload complete
i  hosting[bkc-22519]: finalizing version...
✔  hosting[bkc-22519]: version finalized
i  hosting[bkc-22519]: releasing new version...
✔  hosting[bkc-22519]: release complete

✔  Deploy complete!

Project Console: https://console.firebase.google.com/project/bkc-22519/overview
Hosting URL: https://bkc-22519.web.app

但是当我访问 Url 时,我看到了这个:

而不是我的应用程序的主页。

Firebase 控制台并没有告诉我太多信息,我也看不到实际部署的文件。

浏览器控制台报告这些错误,none 我很清楚如何修复:

firebase-app.js:1442 Uncaught SyntaxError: Unexpected token 'export'
firebase-auth.js:1 Uncaught SyntaxError: Cannot use import statement outside a module
firebase-database.js:1 Uncaught SyntaxError: Cannot use import statement outside a module
firebase-firestore.js:1 Uncaught SyntaxError: Cannot use import statement outside a module
firebase-functions.js:1 Uncaught SyntaxError: Cannot use import statement outside a module
firebase-messaging.js:1 Uncaught SyntaxError: Cannot use import statement outside a module
firebase-storage.js:1 Uncaught SyntaxError: Cannot use import statement outside a module
firebase-analytics.js:1 Uncaught SyntaxError: Cannot use import statement outside a module
firebase-remote-config.js:1 Uncaught SyntaxError: Cannot use import statement outside a module
firebase-performance.js:1 Uncaught SyntaxError: Cannot use import statement outside a module
init.js?useEmulator=true:1 Uncaught Error: hosting/init-error: Firebase SDK not detected. You must include it before /__/firebase/init.js
    at init.js?useEmulator=true:1:44
(index):83 ReferenceError: firebase is not defined
    at HTMLDocument.<anonymous> ((index):69:21)

并不是说我实际上没有使用任何 firebase 服务(firestore、数据库、auth 等)——我正在 运行ning 进行的测试是一个带有一些图像的普通 html 页面.

如何找出这里出了什么问题?

以防其他人遇到此问题,这就是发生这种情况的原因。

在 Firebase 控制台中,如果您设置了转发,系统会指示您将“A”记录添加到您的 DNS。看起来像:

注意“主机”字段,Google建议输入网址。但是至少在 GoDaddy 上(不确定其他注册商)您需要在主机字段中放置“@”。如果你输入域名本身,它是行不通的。它甚至不会加载本地站点 如果这个设置错了,连googlelink到你的网页上。该应用程序将显示错误。