firebase-tools icon indicating copy to clipboard operation
firebase-tools copied to clipboard

Firebase Deploy Command Failed (Error Must supply either "site" or "target" in each "hosting" config.)

Open DragonOsman opened this issue 6 years ago • 7 comments

I tried to run the command `firebase deploy" to deploy an app to Firebase but I had the error I mentioned in parentheses in the title:

 Error: Must supply either "site" or "target" in each "hosting" config.

This is what my .firebaserc file looks like currently:

{
  "projects": {
    "default": "phonestore-4e40c"
  },
  "targets": {
    "phonestore-4e40c": {
      "hosting": {
        "phone-store": [
          "phonestore-4e40c"
        ]
      }
    }
  }
}

What do I do here to fix the error? I tried adding "target": before "phonestore-4e40c" (it would become "target": "phonestore-4e40c") but that didn't work either; it gave me this error:

!  JSON error trying to load E:\programming\angular\phone-store\.firebaserc

=== Deploying to 'phonestore-4e40c'...

i  deploying hosting

Error: Must supply either "site" or "target" in each "hosting" config.

(This is almost the same as the one I got when I ran just firebase deploy; the only thing new is the line about a JSON error).

Any help with this is much appreciated. (Note: The reason I didn't open a "Bug Report" issue is that I wasn't sure if my issue qualifies as a bug report.)

Before that I had tried the ng deploy command since I was following the Angular Getting Started Tutorial and had gotten to the deployment part after following the whole thing (here). I'd chosen to deploy it to Firebase after downloading it to my computer. The result of that was this:

ng deploy
� Building "phone-store"
Generating ES5 bundles for differential loading...
ES5 bundle generation complete.

chunk {2} polyfills-es2015.d39e6b85441999f66523.js (polyfills) 35.6 kB [initial] [rendered]
chunk {3} polyfills-es5.bb7828de73427b5cd027.js (polyfills-es5) 128 kB [initial] [rendered]
chunk {0} runtime-es2015.0811dcefd377500b5b1a.js (runtime) 1.45 kB [entry] [rendered]
chunk {0} runtime-es5.0811dcefd377500b5b1a.js (runtime) 1.45 kB [entry] [rendered]
chunk {1} main-es2015.d600346e98d8457cc378.js (main) 277 kB [initial] [rendered]
chunk {1} main-es5.d600346e98d8457cc378.js (main) 337 kB [initial] [rendered]
chunk {4} styles.f1fcab432634cda74b08.css (styles) 1.68 kB [initial] [rendered]
Date: 2020-03-01T15:29:58.651Z - Hash: 3f6a31e9de18891acf13 - Time: 40448ms
RangeError: Maximum call stack size exceeded
    at formatError (internal/util/inspect.js:1095:20)
    at formatRaw (internal/util/inspect.js:883:14)
    at formatValue (internal/util/inspect.js:737:10)
    at inspect (internal/util/inspect.js:280:10)
    at formatWithOptionsInternal (internal/util/inspect.js:1886:40)
    at format (internal/util/inspect.js:1762:10)
    at Object.console.warn (E:\programming\angular\phone-store\node_modules\@angular\cli\lib\cli\index.js:46:35)
    at Observable._trySubscribe (E:\programming\angular\phone-store\node_modules\@angular-devkit\core\node_modules\rxjs\internal\Observable.js:55:25)
    at Observable.subscribe (E:\programming\angular\phone-store\node_modules\@angular-devkit\core\node_modules\rxjs\internal\Observable.js:30:22)
    at MergeMapOperator.call (E:\programming\angular\phone-store\node_modules\@angular-devkit\core\node_modules\rxjs\internal\operators\mergeMap.js:39:23)
    at Observable.subscribe (E:\programming\angular\phone-store\node_modules\@angular-devkit\core\node_modules\rxjs\internal\Observable.js:25:31)
    at IgnoreElementsOperator.call (E:\programming\angular\phone-store\node_modules\@angular-devkit\core\node_modules\rxjs\internal\operators\ignoreElements.js:27:23)
    at Observable.subscribe (E:\programming\angular\phone-store\node_modules\@angular-devkit\core\node_modules\rxjs\internal\Observable.js:25:31)
    at Object.subscribeToResult (E:\programming\angular\phone-store\node_modules\@angular-devkit\core\node_modules\rxjs\internal\util\subscribeToResult.js:12:23)
    at MergeMapSubscriber._innerSub (E:\programming\angular\phone-store\node_modules\@angular-devkit\core\node_modules\rxjs\internal\operators\mergeMap.js:82:29)
    at MergeMapSubscriber._tryNext (E:\programming\angular\phone-store\node_modules\@angular-devkit\core\node_modules\rxjs\internal\operators\mergeMap.js:76:14)
    at MergeMapSubscriber._next (E:\programming\angular\phone-store\node_modules\@angular-devkit\core\node_modules\rxjs\internal\operators\mergeMap.js:59:18)
    at MergeMapSubscriber.Subscriber.next (E:\programming\angular\phone-store\node_modules\@angular-devkit\core\node_modules\rxjs\internal\Subscriber.js:66:18)
    at Observable._subscribe (E:\programming\angular\phone-store\node_modules\@angular-devkit\core\node_modules\rxjs\internal\util\subscribeToArray.js:5:20)
    at Observable._trySubscribe (E:\programming\angular\phone-store\node_modules\@angular-devkit\core\node_modules\rxjs\internal\Observable.js:44:25)
    at Observable.subscribe (E:\programming\angular\phone-store\node_modules\@angular-devkit\core\node_modules\rxjs\internal\Observable.js:30:22)
    at MergeMapOperator.call (E:\programming\angular\phone-store\node_modules\@angular-devkit\core\node_modules\rxjs\internal\operators\mergeMap.js:39:23)

Would be good if I could get this to work. If not, then the firebase deploy command working would be good too.

DragonOsman avatar Mar 01 '20 15:03 DragonOsman

Okay, something weird must've been happening because I just ran ng deploy again and this time it worked.

DragonOsman avatar Mar 02 '20 11:03 DragonOsman

Thanks @DragonOsman, firebase deploy command not working, I have to use ng deploy command.

nhannqgh avatar Jun 02 '20 05:06 nhannqgh

Getting the same error but found a workaround. "firebase deploy" works for me after adding extra line "target": "app" in the firebase.json config file, as follows:

{ "hosting": [ { "target": "app", "public": "www", ...

shadowboxingskills avatar Jul 01 '20 17:07 shadowboxingskills

Check your firebase.json file, in there there should be a

"hosting": [
    {
      "target": "project-name", <--------------- add this
      "public": "dist/project-name",
      "ignore": [
        "firebase.json",
        "**/.*",
        "**/node_modules/**"
      ]
    },
    ...
    ...
]

yiqu avatar Dec 01 '20 03:12 yiqu

The main problem is having the hosting value as an array. If you set the hosting as an object instead, I think it will use that configuration for all hosting sites/targets.

e.g.

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

davinci-rf avatar Jan 05 '21 03:01 davinci-rf

Solved!!

I just re-ran firebase init, chose my options, and it fixed everything by overwriting the "corrupted" configuration.

sanjay51 avatar Jan 24 '21 21:01 sanjay51

Okay, something weird must've been happening because I just ran ng deploy again and this time it worked.

lmao I got the same error so I decided to google it and after your reply I decided to run ng deploy again. It worked. WHAT? magic(?)

interestingALI avatar Nov 09 '21 17:11 interestingALI