Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase deploy gives numerous errors

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)

like image 210
ruby_arizona Avatar asked Nov 12 '15 21:11

ruby_arizona


People also ask

What script should be run before every deploy Firebase?

The firebase init command creates a firebase. json configuration file in the root of your project directory. The firebase. json file is required to deploy assets with the Firebase CLI because it specifies which files and settings from your project directory are deployed to your Firebase project.

How do you update a file that I deployed to Firebase hosting?

You cannot change hosted files in the Firebase Console. Instead, you should change the index. html on your local copy where you initially ran the firebase deploy command. Once you're done with the changes, run firebase deploy again to push the updated version of your website to Firebase Hosting.

Where is my Firebase json file?

Firebase automatically creates your firebase. json file at the root of your project directory when you run the firebase init command.


5 Answers

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!

like image 105
Mehrnoosh Avatar answered Oct 19 '22 18:10

Mehrnoosh


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. ... )

like image 29
Tanvir Haider Avatar answered Oct 19 '22 18:10

Tanvir Haider


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.

like image 40
pavitran Avatar answered Oct 19 '22 16:10

pavitran


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

like image 32
Takwa Joobeur Avatar answered Oct 19 '22 18:10

Takwa Joobeur


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

{
  "hosting": {
    "public": "dist/",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  }
}
like image 1
ASCII ALIEN Avatar answered Oct 19 '22 18:10

ASCII ALIEN