8
votes

Note: I am a coding newbie.

I had a Divshot app that I now have to migrate to Firebase. It contains two HTML files, one stylesheet, and one local jpg file. There's no JavaScript. It's super basic. I know.

I have followed the CLI directions and done the tutorial for Firebase. (Unsure why I was building a random chat app.) I also tried the --help command and its suggestions.

The "firebase.json" file has been created in my app's directory, as has the folder labeled "public". I moved the html docs, stylesheet and jpg into the "public" folder since the CLI told me there must be at least one file in the public directory. Should it have been a zip file?

Then I tried again, and was told

"Public directory does not contain index.html"

even though it definitely does.

I also added the firebase script in the header of each html doc. Unsure if that was correct.

My app is all static, right? I just want my firebase URL to display the content of my HTML pages with the style rules in the stylesheet. How do I do this/what am I missing?

Some errors I got, in order:

Error: Must have at least one file in public directory to deploy.

(moved files into "public" directory)

Error: Not in a Firebase app directory (could not locate firebase.json)

(idk why, because it was there)

Error: Specified public directory does not exist, can't deploy hosting

(such a lie)

9
Hello - can you please share the contents of your firebase.json config file? This file specifies which folder is the "public" directory. We need to make sure it matches up with the name of the directory where you put the files.Andrew Lee

9 Answers

7
votes

For me, I had same problem when i want to deploy had this error:

Error: Specified public directory does not exist, can't deploy hosting  

I run this code in terminal in root of firebase project :

yarn build

It works!

5
votes

public directory isn't the current directory you are in but the one that you specify when it asks
What do you want to use as your public directory?
after you complete the initialization with firebase init your current directory should contain two files firebase.json, .firebaserc and a folder which is the public directory where your index.html file should be.only then you can deploy you site with firebase deploy.
if all the above condition are met and you current directory isn't the public directory than please share your debug log from the console.

3
votes

i resolved this issue by updating the firebase.json file's public directory to "/"

hosting: { public: "/" ...

i had to make sure that the firebase.json file was located in the same location as other files (index.html. ... )

2
votes

I had the same issue (angular) and resolved by running npm run-script build then firebase deploy again.

1
votes

IN firebase.json I DID A (angular) "dist/"

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

I had the same issue, but I resolved this by creating another temporary folder within src folder named it 'dist' and copied all the files in the original dist folder and ran 'firebase deploy' and it worked! I then deleted the temporary folder 'dist' after deployment.

0
votes

Means it cannot find a folder named "public". I moved the firebase.json & .firebaserc file up a folder and ran the deploy from there. Also changed the "public" element in the .json file to my project folder name.

0
votes

For removing firebase hosting deployment errors (also if you are updating existing hosted site) you can do process again 1] firebase login 2] firebase init 3] firebase deploy

Make sure your current folder has two things: public folder (which contains all website file like css images etc including index.html) And firebase.json file

0
votes

try ng build --prod and, after that firebase deploy.

If you are using Github-auto-deploy: put "public": "dist/X", in your firebase.json where X=your project name