ruby_arizona
ruby_arizona

Reputation: 81

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)

Upvotes: 8

Views: 29361

Answers (11)

In my case it works whit: $ npm run build and then: $ firebase deploy

Upvotes: 0

Wizlab Solution
Wizlab Solution

Reputation: 11

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

hosting: { public: "/" ...

Yeah it's worked !

Upvotes: 1

Elisei Nicolae
Elisei Nicolae

Reputation: 352

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

Upvotes: 0

Takwa Joobeur
Takwa Joobeur

Reputation: 31

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

Upvotes: 3

Snehil Chouhan
Snehil Chouhan

Reputation: 119

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

Upvotes: 0

ASCII ALIEN
ASCII ALIEN

Reputation: 81

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

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

Upvotes: 1

Tanvir Haider
Tanvir Haider

Reputation: 101

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

Upvotes: 10

Nicholas Ibarra
Nicholas Ibarra

Reputation: 504

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.

Upvotes: 0

Temmix
Temmix

Reputation: 1

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.

Upvotes: 0

Mehrnoosh
Mehrnoosh

Reputation: 899

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!

Upvotes: 8

pavitran
pavitran

Reputation: 814

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.

Upvotes: 5

Related Questions