Firebase-tools: Error: Hosting target (project-name) not detected in firebase.json

Created on 22 Oct 2020  Â·  22Comments  Â·  Source: firebase/firebase-tools

[REQUIRED] Environment info

firebase-tools:v8.13.1

Platform:macOS

[REQUIRED] Test case

firebase deploy --only hosting:(project-name)

[REQUIRED] Steps to reproduce

I'm using the following Github action: https://github.com/w9jds/firebase-action/ which uses the latest release of firebase-tools.
Since the last update, it's not working anymore. I had to manually set to an older version of firebase-tools (I went for v8.12.1, I haven't tried with v8.13.0)

[REQUIRED] Expected behavior

Successful deploy

[REQUIRED] Actual behavior

Deploy error
Error: Hosting target (project-name) not detected in firebase.json

Attention

Most helpful comment

npm install -g [email protected]
Then:
firebase deploy --only hosting:project-name
works for me

All 22 comments

I am able to replicate this with firebase deploy --only hosting:<project>. Taking a look...

Question for you @pflevy -

on v8.12.1, I actually cannot directly do firebase deploy --only hosting:<project-name>. The --only hosting:<target> syntax is actually for deploying to Hosting _targets_ in a multi-site setup. More information on that: https://firebase.google.com/docs/hosting/multisites#cli-commands-with-deploy-targets

Do you have those targets set up and are you using the correct name? I can poke around a bit more, but specifically doing --only hosting:<SITE-name> (which may be the same as the project name) is not supported.

Same issue here with 8.13~

I use firebase deploy --only hosting:x-x-x for almost 2 years.

ludufre@iMac ludufre % npm i -g [email protected]

npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: this library is no longer supported
/Users/ludufre/.npm-packages/bin/firebase -> /Users/ludufre/.npm-packages/lib/node_modules/firebase-tools/lib/bin/firebase.js
+ [email protected]
updated 1 package in 26.881s
ludufre@iMac ludufre % firebase deploy --only hosting:x-x-x

=== Deploying to 'x-x'...

i  deploying hosting

Error: Hosting target x-x-x not detected in firebase.json
````

When rollback to 8.12:

```bash
ludufre@iMac ludufre % npm i -g [email protected]                
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: this library is no longer supported
/Users/ludufre/.npm-packages/bin/firebase -> /Users/ludufre/.npm-packages/lib/node_modules/firebase-tools/lib/bin/firebase.js
+ [email protected]
updated 1 package in 7.532s
ludufre@iMac ludufre % firebase deploy --only hosting:x-x-web

=== Deploying to 'x-x'...

i  deploying hosting
i  hosting[x-x-x]: beginning deploy...
i  hosting[x-x-x]: found 311 files in platforms/browser/www
✔  hosting[x-x-x]: file upload complete
i  hosting[x-x-x]: finalizing version...
✔  hosting[x-x-x]: version finalized
i  hosting[x-x-x]: releasing new version...
✔  hosting[x-x-x]: release complete

✔  Deploy complete!

Project Console: https://console.firebase.google.com/project/x-x/overview
Hosting URL: https://x-x-x.x.x
ludufre@iMac ludufre % 

I've had this same problem start happening from last night.
I use the following in my CI pipeline:

firerbase use PROJECTNAME --token $FIREBASE_TOKEN
firebase deploy --only hosting:SITE

I now get the error:

Hosting target SITE not detected in firebase.json

Nothing else has changed on this project or CI defintion for months

Same here... since two days
I am using deploy -P <PROJECT> --only hosting:<SITE NAME>

Same here. I've always used firebase deploy --only hosting:<name>

Question for you @pflevy -

on v8.12.1, I actually cannot directly do firebase deploy --only hosting:<project-name>. The --only hosting:<target> syntax is actually for deploying to Hosting _targets_ in a multi-site setup. More information on that: https://firebase.google.com/docs/hosting/multisites#cli-commands-with-deploy-targets

Do you have those targets set up and are you using the correct name? I can poke around a bit more, but specifically doing --only hosting:<SITE-name> (which may be the same as the project name) is not supported.

In this specific case, I only use one site and I don't have the target set up on firebase.json. I actually tried adding it as
target: <project-name> but it didn't work.

Also, I do have another project where I rely on the same action and make use of two sites. But I also don't have the 'target' set on firebase.json and only pass it as a flag deploy --only hosting:<SITE-name>, which has always worked fine.

From what you just said I assume the correct approach would be to use firebase deploy --only hosting for when there's a single site, and for multiple sites, it's required to define the targets in firebase.json before running deploy --only hosting:<SITE-name>. I wonder what could've gone wrong then since it also didn't work by adding target: <project-name> under "hosting".

Worked for me, this way (specific firebase-tools version 8.12):

npm install -g [email protected]

Then:

firebase deploy -f --project my-project-name --only hosting:my-project-name

Ack. Thanks everyone for the insights. If we regressed this behavior, makes sense to me that we should restore it. I'll look into it this morning.

I was presented with the same problem and using an older version of firebase-tools solved the problem. Thanks for your comments. Greetings.

@bkendall How should hosting be specified until a fix is up?

Having same issue on local windows machine. I was on an older version of firebase-tools (probably 7... something) then upgraded and that didn't fix the issue. Then installed version 8.12, added the "site" property to my firebase.json file and then deployed as usual with "firebase deploy --only hosting:SITENAME"

npm install -g [email protected]
Then:
firebase deploy --only hosting:project-name
works for me

npm install -g [email protected]
firebase deploy --only hosting:project-name

works for me as well

I get the same issue with no changes to firebase config

I also get the same issue with the latest version of firebase when installed using curl -sL https://firebase.tools | bash

Using [email protected] fixed the issue for me as well.

This will go out in the next release of firebase tools. Thanks for your patience.

Having the same issue...

Same problem since 3 days using :
firebase -P PROJ_NAME deploy -m "MESSAGE" --only hosting:SITE_NAME
results in

Error: Hosting target SITE_NAME not detected in firebase.json

@bkendall How should hosting be specified until a fix is up?

Follow https://firebase.google.com/docs/hosting/multisites#set_up_deploy_targets

TL;DR

  1. add target id to .firebaserc firebase target:apply hosting blog myapp-blog
  2. add target entry to your firebase.json
  3. deploy

it solved the problem for me with multiple sites in one hosting project

This should be fixed in v8.14.0. Thanks for y'alls patience.

I had the same problem: Hosting target (project-name) not detected in firebase.json

I looked at .firabaserc and get the target name

targets": { "XXXXX": { "hosting": { "Teste": [ "XXXXX" ] } }

Then, I ran firebase deploy --only hosting:XXXXX and it worked.

Was this page helpful?
0 / 5 - 0 ratings