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)

Most upvoted comments

I solved mine by making sure:

  1. .firebaserc must have targets.<PROJECT_ID>.hosting.<TARGET_NAME> = [ "<HOST_ID" ]
{
  "projects": {
    "default": "my-project-id"
  },
  "targets": {
    "my-project-id": {
      "hosting": {
        "my-blog": [
          "my-blog-host-id"
        ]
      }
    }
  }
}

The targets part can be generated using command firebase target:apply hosting my-blog my-blog-host-id

  1. firebase.json must have hosting as an array, and its item must have target: <TARGET_NAME>
{
  "hosting": [{
    "target": "my-blog",
    "public": "public",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  }]
}

The important part is making hosting an array, and add target to 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.json config file have "target": "dev" in it? I believe that we filtered out all of the configs that didn’t match hosintg:dev and 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.json file is set up in such a way that you’d be able to something like firebase 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 myapp

and added target key to my firebase.json

{
  "hosting": {
    "target": "myapp",
    ...
  }
  ...
}

edit: 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?

[debug] [2019-08-16T18:44:01.159Z] TypeError: Cannot read property 'deploys' of undefined
    at C:\Users\Kraken\AppData\Roaming\npm\node_modules\firebase-tools\lib\deploy\index.js:84:36
    at process._tickCallback (internal/process/next_tick.js:68:7)
[error] 
[error] Error: An unexpected error has occurred.

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

  1. Domain was not fully linked
  2. Firebase.json of hosting was modified as per documentation When both are done, it worked properly as expected

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:

"targets": {
    "firebase-project-name": {
      "hosting": {
        "admin": [
          "admin-project"
        ]
      }
    }
  }