firebase-tools: Cannot read property 'deploys' of undefined
Environment info
firebase-tools: firebase-tools@6.7.2
Platform: MacOS
Test case
MacOS, Node 10.15.3, firebase-tools@6.7.2
Steps to reproduce
Create two hosting sites on firebase console. Run ‘firebase target:apply hosting dev firebase-hosting-id’ Run ‘firebase deploy --only hosting:dev’
Expected behavior
Deployment successful
Actual behavior
[info] Project Console: https://console.firebase.google.com/project/project-name/overview
[debug] [2019-05-01T19:12:12.726Z] TypeError: Cannot read property 'deploys' of undefined
at /Users/reeda/.nvm/versions/node/v10.15.3/lib/node_modules/firebase-tools/lib/deploy/index.js:88:36
at process._tickCallback (internal/process/next_tick.js:68:7)
[error]
[error] Error: An unexpected error has occurred.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 15
- Comments: 37 (10 by maintainers)
I solved mine by making sure:
targets.<PROJECT_ID>.hosting.<TARGET_NAME> = [ "<HOST_ID" ]The
targetspart can be generated using commandfirebase target:apply hosting my-blog my-blog-host-idhostingas an array, and its item must havetarget: <TARGET_NAME>The important part is making
hostingan array, and addtargetto its item.@MaxInertia yes I resolved it, I formatted and erased my entire machine 😃
I think I may know what is going on here. Does your
firebase.jsonconfig file have"target": "dev"in it? I believe that we filtered out all of the configs that didn’t matchhosintg:devand we were left with an empty array. We then went through all of the deploy steps for that empty array, effectively doing nothing. Then at the end we display the console link and the link to your newly deployed Hosting Site, which is where this error pops up because we didn’t actually deploy anything.We definitely need a proper error in this case explaining that we’re not deploying anything.
(unrelated to the issue: generally you want to have your environment level switching be on a Firebase project level basis and not on different Hosting Sites within the same project (though you might have a Site for a blog, a Site for a web app, and a Site for your Docs that are all in the same environment on different Hosting Sites on the same project). This is mainly because things like Firebase Auth have only a single instance within a project. Ideally your
firebase.jsonfile is set up in such a way that you’d be able to something likefirebase use dev,firebase deploy, check dev to make sure things are working,firebase use staging,firebase deploy, …)I was able to resolve this issue by creating a new deploy target with the help of this guide:
https://firebase.google.com/docs/hosting/multisites?authuser=1#set_up_deploy_targets
I issued one command:
firebase target:apply hosting blog myappand added
targetkey to myfirebase.jsonedit: I stepped into this issue when I set up my first hosting on my brand new firebase project.
@hpoit I’m also getting that error. Did you resolve it? If so what did you change?
Has this been resolved for anyone that’s contacted support as @Memeriaj suggested? If so could the details be posted here for future reference?
Hi @mbleigh ,
I got my issue resolved
If there is no more queries we can close this issue In case of having queries please comment below
I was able to resolve it as well. My issue was that when I created my deploy target using the command outlined in the docs: $firebase target:apply hosting target-name resource-name, I had put my main project as the resource name. I changed that in the .firebaserc file and ran the firebase deploy command and it worked. Example below: