I want to host a website in Firebase. I followed the instruction Firebase gave me and there is an instruction says: Add your static files to your deploy directory (the default is public). I don't know what it means, so I just entered the code under this instruction, which is: firebase deploy, and the command prompt responded with: Error: Cannot understand what targets to deploy. Check that you specified valid targets if you used the --only or --except flag. Otherwise, check your firebase.json to ensure that your project is initialized for the desired features. Do I need to create a static file? I don't really know what to do next. The link to the instruction is here: https://console.firebase.google.com/project/example-website/hosting , you need to sign into Google in order to access it.
How do I host on Firebase?
1.3k views Asked by Asension At
2
There are 2 answers
0
On
The error you are getting because JSON file is missing. which mean you have not correctly initialize firebase project. Follow these steps to do it correctly:
- After installing firebase, from your console enter 'firebase login' and login with your gmail account.
- Now enter 'firebase init' and select hosting option by using Space key and press enter and also select your project.(don't forget to press space tab on correct option) It will ask about public folder, just press enter.
- Then will ask if your app is single page app. Press Y or N and enter.
- Now you will get a public folder, inside will be a index.html file. Open it and do some changes if you want. Now from console enter 'firebase deploy'
- It's time to connect your domain, if you have any. Under hosting, now you will see new option 'Connect Domain'. Click on it and follow the instructions. I have connected my domain parimeo same way to firebase. If you don't want to connect any domain then firebase will also provide you a link to your web app.
Try initializing your project with the CLI as explained here: https://firebase.google.com/docs/cli/
As mentioned there "The init command steps you through setting up your project directory, including asking which Firebase features you want to use." With the features correctly declared you will be able to run firebase deploy without any error