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

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

Open pflevy opened this issue 6 years ago • 36 comments

[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

pflevy avatar Oct 21 '20 23:10 pflevy

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

bkendall avatar Oct 22 '20 00:10 bkendall

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 avatar Oct 22 '20 00:10 bkendall

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:

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 % 

ludufre avatar Oct 22 '20 06:10 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

spenceclark avatar Oct 22 '20 09:10 spenceclark

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

vin-fandemand avatar Oct 22 '20 12:10 vin-fandemand

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

AnaWhibley avatar Oct 22 '20 14:10 AnaWhibley

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

pflevy avatar Oct 22 '20 14:10 pflevy

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

stanleygomes avatar Oct 22 '20 15:10 stanleygomes

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.

bkendall avatar Oct 22 '20 15:10 bkendall

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

Angel-Q87 avatar Oct 22 '20 15:10 Angel-Q87

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

MichaelDCooper avatar Oct 22 '20 19:10 MichaelDCooper

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"

comeacross1989 avatar Oct 23 '20 02:10 comeacross1989

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

ThaDeveloper avatar Oct 23 '20 07:10 ThaDeveloper

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

works for me as well

matheuscouto avatar Oct 23 '20 10:10 matheuscouto

I get the same issue with no changes to firebase config

medin-n avatar Oct 23 '20 22:10 medin-n

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.

mark-gene avatar Oct 26 '20 11:10 mark-gene

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

bkendall avatar Oct 26 '20 17:10 bkendall

Having the same issue...

Teepath avatar Oct 26 '20 17:10 Teepath

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 avatar Oct 26 '20 18:10 alkeicam

@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

alkeicam avatar Oct 26 '20 18:10 alkeicam