Error deploying Angular application on Firebase

只谈情不闲聊 提交于 2019-12-24 12:16:25

问题


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:


After you run firebase init

Press SPACE to select hosting, then Enter to confirm.



来源:https://stackoverflow.com/questions/46013826/error-deploying-angular-application-on-firebase

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!