![](/img/trans.png)
[英]Angular + Firebase hosting: how to use static js file in website root?
[英]Firebase hosting static website not working
我正在嘗試在 firebase 上托管 static 網站。 (使用 macOS Catalina)我用 npm 安裝了 firebase CLI。 我網站的目錄名為 Knight 登錄后,我運行以下命令:
firebase init
然后我選擇了以下內容:您要為此文件夾設置哪些 Firebase CLI 功能?
hosting
你想用什么作為你的公共目錄?
public (I also tried dist and knight and Knight and KNIGHT)
配置為單頁應用(將所有 url 重寫為 /index.html)?
Y ( I also tried No )
文件 public/index.html 已經存在。 覆蓋?
N
然后初始化過程就完成了。 當我嘗試firebase serve
並到達 http://localhost:5000 時,我得到了 firebase 歡迎頁面。
如何查看我的網站? 我做錯什么了嗎?
Firebase CLI 使用的過程非常簡單:
firebase init
index.html
和其他 web 文件相對於您運行firebase.init
的目錄的路徑的問題既然你說你在Knight
有你的 web 站點,你應該回答“你想用什么作為你的公共目錄?” 與Knight
。
更新:您似乎在index.html
文件所在的同一目錄中運行firebase init
命令。 在這種情況下,您的“公共方向”是.
,因為它與項目所在的目錄相同。
好的,我發現了問題。 After searching for firebase.json
on my machine I realized that firebase was writing the files in my user directory, instead of writing them where I called firebase init. 所以我的index.html
路徑看起來像:
/Users/DCI/Documents/Knight/index.html
但是 firebase 正在將文件寫入:
/Users/DCI
所以我要做的就是將Documents/Knight
作為 firebase init 的公共目錄。 完成此操作后,我調用了 firebase 服務和 firebase 部署,它運行良好。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.