Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Hosting target (project-name) not detected in firebase.json #2731

Closed
pflevy opened this issue Oct 21, 2020 · 35 comments · Fixed by #2733
Closed

Error: Hosting target (project-name) not detected in firebase.json #2731

pflevy opened this issue Oct 21, 2020 · 35 comments · Fixed by #2733
Assignees

Comments

@pflevy
Copy link

pflevy commented Oct 21, 2020

[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

@bkendall
Copy link
Contributor

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

@bkendall bkendall self-assigned this Oct 22, 2020
@bkendall
Copy link
Contributor

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.

@bkendall bkendall added the Needs: Author Feedback Issues awaiting author feedback label Oct 22, 2020
@ludufre
Copy link

ludufre commented Oct 22, 2020

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 firebase-tools@8.13

npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: 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
+ firebase-tools@8.13.1
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:

ludufre@iMac ludufre % npm i -g firebase-tools@8.12                
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: 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
+ firebase-tools@8.12.1
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 % 

@spenceclark
Copy link

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

@vin-fandemand
Copy link

vin-fandemand commented Oct 22, 2020

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

@AnaWhibley
Copy link

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

@pflevy
Copy link
Author

pflevy commented Oct 22, 2020

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".

@google-oss-bot google-oss-bot added Needs: Attention and removed Needs: Author Feedback Issues awaiting author feedback labels Oct 22, 2020
@stanleygomes
Copy link

stanleygomes commented Oct 22, 2020

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

npm install -g firebase-tools@8.12

Then:

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

@bkendall
Copy link
Contributor

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.

@Angel-Q87
Copy link

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

@MichaelDCooper
Copy link

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

@comeacross1989
Copy link

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"

@ThaDeveloper
Copy link

npm install -g firebase-tools@8.12
Then:
firebase deploy --only hosting:project-name
works for me

@matheuscouto
Copy link

npm install -g firebase-tools@8.12
firebase deploy --only hosting:project-name

works for me as well

@medin-n
Copy link

medin-n commented Oct 23, 2020

I get the same issue with no changes to firebase config

@mark-gene
Copy link

mark-gene commented Oct 26, 2020

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

Using firebase-tools@8.12 fixed the issue for me as well.

@bkendall
Copy link
Contributor

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

@Teepath
Copy link

Teepath commented Oct 26, 2020

Having the same issue...

@alkeicam
Copy link

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

@alkeicam
Copy link

alkeicam commented Oct 26, 2020

@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

@bkendall
Copy link
Contributor

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

@RoCampos
Copy link

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.

@sonicwim-zz
Copy link

sonicwim-zz commented Dec 9, 2020

I tried the Angular tutorial from https://angular.io/start and then tried to deploy it from my local copy to Firebase but I also needed to specify the target as @RoCampos said.

And I'm using version 8.18.0, any idea why this is still happening?

@bkendall
Copy link
Contributor

bkendall commented Dec 9, 2020

@SonicWim if you could open a new issue with more details, that would be super helpful. Please include all the relevant parts of firebase.json and --debug output.

@sonicwim-zz
Copy link

sonicwim-zz commented Dec 9, 2020

I will do that.
But as I'm filing it I can't seem to make it work again, ng deploy still fails but firebase deploy --debug works... :-/
When I surf to the Hosting URL I get a message that the hosting is complete and only a button to open the documentation but no running project.

I'll see if I can reproduce the error tomorrow.

@sonicwim-zz
Copy link

As I'm a noob on Github I could not find back this thread after posting my message so I could also not let you know that my problem is solved, it was a because I misinterpreted an instruction (about the default project name) off the tutorial.

Tips on navigating to your posts would be appreciated... ;-)

And I only found this page back because I got a mail today of someone saying happy new year but this seems to be removed already.

@medin-n
Copy link

medin-n commented Feb 3, 2021

And I only found this page back because I got a mail today of someone saying happy new year but this seems to be removed already.

Yeah the Happy new year message confused me a lot

@sonicwim-zz
Copy link

Is there a way, @usamedin, to see your forum activity? I can't seem to find it...

@medin-n
Copy link

medin-n commented Feb 3, 2021

@SonicWim try https://github.com/notifications/subscriptions, when you comment on a thread you are auto-subscribed to it

@sonicwim-zz
Copy link

Thanks for the tip man! I only got notifications about new posts by mail and that's fine but here I wanted to reply back to say that my problem was not really a problem at all but a PEBKAC but I could not find the issue thread any more... 😄

@maurocolella
Copy link

Has this ever been fixed?

@lericslh
Copy link

lericslh commented Jun 17, 2021

only open the directory and open firebase.json

and add "site": "site-name"

below the second line "hosting"

@dnishiyama
Copy link

dnishiyama commented Aug 6, 2021

I ended up here because I hadn't followed the full procedure for setting up multi-site hosting. This url had all the info I needed: https://firebase.google.com/docs/hosting/multisites

I needed to run firebase hosting:sites:create SITE_ID
Then firebase target:apply hosting TARGET_NAME SITE_ID
Then I had to modify firebase.json for multi-site hosting as suggested in Step 4: "hosting": [ { "target": {TARGET_NAME}, // "blog" is the applied TARGET_NAME for the Hosting site "myapp-blog" "public": "blog/dist",
Hope that helps someone

momargoh added a commit to momargoh/diario that referenced this issue Feb 6, 2023
momargoh added a commit to momargoh/diario that referenced this issue Feb 6, 2023
@AndyKgotatso
Copy link

AndyKgotatso commented Nov 12, 2023

Found it!

Follow steps here - https://firebase.google.com/docs/cli/targets

  1. Make sure you DON'T remove "etags": {} from the .firebaserc file

@Nano1408
Copy link

Ami me funciono cerrando sesión con el comando "firebase logout" y volver a iniciar sesión con "firebase login", esto refresca los CLI de recopilación de información, después le hice el despliegue normal sin generar el error "Error: Cannot deploy a web framework from source because the experiment webframeworks is not enabled. To enable webframeworks run firebase experiments:enable webframeworks".

Comparto pasos para los que le funcione:
Paso 1: Cerrar sesión "firebase logout"
paso 2: iniciar sesión "firebase login" -> esto refresca los CLI y Emulator Suite para los permisos en tu cuenta firebase
paso 3: desplegar cambios "firebase deploy"

Antes
Captura de Pantalla 2024-04-28 a las 1 20 12 a m

Después
Captura de Pantalla 2024-04-28 a las 1 20 55 a m

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.