![](/img/trans.png)
[英]'npm' is not recognized as an internal or external command, while hosting website using Firebase
[英]Unable to display website using Firebase Hosting
我正在嘗試使用 Firebase 托管來托管我的動態 Node.js 網站,但根據我的文件結構,我遇到了困難。 這是看起來的樣子:
在我的代碼中,我沒有使用 index.html 文件,但是當我運行firebase init
時,它會自動為我創建一個 404.html 文件。 當我部署我的代碼時,似乎只有 index.html 文件在執行。 但是當我在刪除 index.html 文件后嘗試部署時,我可以看到 404.html 文件。
這是 firebase.json 文件。 我正在使用:
{
"hosting": {
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
]
}
}
“public/html”文件夾中的所有文件似乎都沒有執行。 我嘗試在 firebase.json 文件中將公共字段更改為 public/html,但隨后我只能在部署時看到Cannot GET /
。 與“src/js”文件夾中的 js 文件一起部署時,如何運行“public/html”文件夾中的文件?
我的代碼中有一個錯誤。html 文件位於“public/html/main”下。 如果我想在 404.html 文件之外使用它,我必須直接放在公用文件夾中嗎?
此外,我還有很多后端文件。 為了使用這些,我是否需要使用 firebase 提供的其他服務,或者可以通過使用 Firebase 托管本身來完成?
使用 Firebase 托管,如果您想在加載“/”路徑時查看 web 內容,則需要在公共目錄中創建一個名為“index.html”的文件。 它不會在子目錄中查找。 默認情況下,使用您顯示的配置,所有路徑都相對於公共提供。
很難說出您期望以不同的方式工作。 如果你想引用嵌套在 html 下的 foo.html,那么你的路徑需要是“/html/foo.html”。 如果您想更改托管配置以做不同的事情,我建議您查看文檔。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.