简体   繁体   中英

Firebase: This file does not exist and there was no index.html found in the current directory or 404.html in the root directory

I am facing a problem with deploying my website with firebase.

I have deployed but it keeps showing an error "This file does not exist and there was no index.html found in the current directory or 404.html in the root directory.".

显示的错误图像

I have checked the directory but index.html file is in public folder.

firebase.json, code as below

{
  "hosting": {
    "public": "public",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  }
}

Can anyone point out what the problem is? Thank you.

When using React, you deploy the build (usually named as "build" or "dist") directory and not that "public". First run the build command npm run build and then it should generate the directory that I mentioned earlier.

Then update the same in your firebase.json :

{
  "hosting": {
    "public": "build", // <-- use that directory name here
     ....
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM