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.
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)
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.
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.
Firebase automatically creates your firebase. json file at the root of your project directory when you run the firebase init command.
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!
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. ... )
public directory isn't the current directory you are in but the one that you specify when it asksWhat 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.
I had the same issue (angular) and resolved by running npm run-script build
then firebase deploy
again.
IN firebase.json I DID A (angular) "dist/"
{
"hosting": {
"public": "dist/",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With