firebase-tools: Hosting deploy fails with multiple sites in the project
firebase --version : 4.2.1 os: Mac OS High Sierra (10.13.5)
After I have added a second site to the same project the deploy is failing. In the debug it is giving the following message when I run a deploy command: cmd: firebase deploy --only hosting:dealer
[info] Project Console: https://console.firebase.google.com/project/[project]-dev/overview [debug] [2018-08-31T18:22:18.699Z] TypeError: Cannot read property 'deploys' of undefined at /Users/[user]/.npm-global/lib/node_modules/firebase-tools/lib/deploy/index.js:105:32 at <anonymous> at process._tickDomainCallback (internal/process/next_tick.js:228:7) [error] [error] Error: An unexpected error has occurred.
And this is my .firebaserc file:
{
"projects": {
"default": "[name]-dev",
"prod": "[name]-prod"
},
"targets": {
"[name]-dev": {
"hosting": {
"dealer": [
"[name]-dealer-dev"
],
"consumer": [
"[name]-dev"
]
}
}
}
}
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 13
- Comments: 18 (5 by maintainers)
Commits related to this issue
- Merge pull request #902 from FirebasePrivate/hlshen/stream initial stream compile errors implementation — committed to firebase/firebase-tools by hlshen 3 months ago
I also got this error but i fixed it by changing my
firebase.json
config to use an array with a hosting configuration for each site.old
firebase.json
updated
firebase.json
My
.firebaserc
@arsen Thanks for bringing this to our attention. It seems as though that happens when a hosting deploy target name that doesn’t exist in
firebase.json
. I’ve brought this to the attention of the appropriate people. 😄When using multiple Hosting sites, it’s important to follow all the directions in the documentation in order for deployments to work. The cliff notes version going from one to two sites (where the project name is
my-web-app
:new-site
)firebase target:apply [some-target-name] my-web-app
to give a name to to the original sitefirebase target:apply [new-target-name] new-site
in the terminal in your projectfirebase.json
to make thehosting
object an array, being sure to specify in each element thetarget
value"target": "[some-target-name]",
to the original object so that the default site can continue to be deployedfirebase deploy --only hosting
should deploy bothsome-target-name
andnew-target-name
, andfirebase deploy --only hosting:some-target-name
will only deploysome-target-name
.Hope this helps!
Same problem and put an array didn’t work.
@vnoitkumar you must be on the Blaze plan to create multiple Hosting sites. See the note here: https://firebase.google.com/docs/hosting/multisites
I was able to resolve this by updating the main
firebase.json
configration. The issue was in the hosting reference syntax, which needs to be updated using anarray
formate instead of thebrackets
formate.Initial file – generated by firebase:
Updated file, with revising hosting section:
I’m only using 2 enviornments in this case. I did not have to make any updates to the
.firebaserc
file.I was facing the same problem, I try @danielx suggestion and it works. So, this error occurred because the firebase.json file didn’t get update when I run the
firebase target:apply hosting target-name resource-name
command.