Error deploying Angular application on Firebase

1.3k Views Asked by At

I tried deploying my angular 4 application on firebase but the setup did not ask me for any configuration as mentioned here: https://alligator.io/angular/deploying-angular-app-to-firebase/ and many similar answers on stack. Out of following 5 steps that firebase cli runs through on running firebase init, I was only asked for step1 and not for others.

  1. Firebase CLI features…: Hosting.
  2. Database rules file: You can keep that default file name that they provide, or change it if you prefer. This file will be created and will contain the database rules for your app.
  3. Public directory: Type in dist, because this is where your production-ready Angular app assets are.
  4. Configure as single-page app: Most of the time you’ll say yes (y) for this one.
  5. Overwrite index.html: No.

Hence the firebase.json generated in root directory was empty:

{}

Then when I ran firebase deploy, I got this error:

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.

I then googled for the firebase.json content that should have been created normally, then I pasted the below in json and deployed, it was successful:

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

Any reason why firebase didnot ask for configuration? Am I using the right content in firebase.json? I found "ignore" setup as well in this file here. Can anyone share the correct content. TIA.

1

There are 1 best solutions below

0
On

After you run firebase init

Press SPACE to select hosting, then Enter to confirm.