question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hosting deploy fails with multiple sites in the project

See original GitHub issue

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"
        ]
      }
    }
  }
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:13
  • Comments:17 (5 by maintainers)

github_iconTop GitHub Comments

60reactions
danielxcommented, Sep 12, 2018

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

{
  "hosting": {
    "public": "dist",
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  }
}

updated firebase.json

{
  "hosting": [
    {
      "target": "production",
      "public": "dist",
      "rewrites": [
        {
          "source": "**",
          "destination": "/index.html"
        }
      ]
    },
    {
      "target": "staging",
      "public": "dist",
      "rewrites": [
        {
          "source": "**",
          "destination": "/index.html"
        }
      ]
    }
  ]
}

My .firebaserc

{
  "projects": {
    "default": "[project-id]"
  },
  "targets": {
    "[project-id]": {
      "hosting": {
        "production": [
          "[project-id]"
        ],
        "staging": [
          "[project-id]-staging"
        ]
      }
    }
  }
}
17reactions
bkendallcommented, Sep 28, 2018

@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:

  • create a new site in the Firebase Console under Hosting (e.g. new-site)
  • run firebase target:apply [some-target-name] my-web-app to give a name to to the original site
  • run firebase target:apply [new-target-name] new-site in the terminal in your project
  • update firebase.json to make the hosting object an array, being sure to specify in each element the target value
    • be sure to add "target": "[some-target-name]", to the original object so that the default site can continue to be deployed
    • a sample configuration may look like this (w/o comments, 'cause JSON):
{
  "hosting": [
    {
      "target": "some-target-name",
      "public": "dist", // this was the original deployed folder, now with `target` above
    },
    {
      "target": "new-target-name", // this is a new `target` and object
      "public": "new-dist",
    }
  ]
}
  • now firebase deploy --only hosting should deploy both some-target-name and new-target-name, and firebase deploy --only hosting:some-target-name will only deploy some-target-name.

Hope this helps!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issue with multiple sites deployment in Firebase - Stack Overflow
Both sites located in the same Hosting of "my-app" project on Google Firebase. Can someone please help me and explain what have I...
Read more >
Hosting: How to deploy multiple directories? - Google Groups
The deployment of multiple directories to firebase hosting fails. In my firebase.json I define two directories: "public": ["public", "config/gcp_tst"].
Read more >
Deploy Multiple Sites to Firebase Hosting - Fireship
Learn how manage multiple sites from a single Firebase project.
Read more >
Share project resources across multiple sites | Firebase Hosting
By setting up multiple Hosting sites within the same Firebase project, you can more easily share Firebase resources between related sites and apps....
Read more >
One project, multiple sites! Plus a boost in upload speed!
Do you wish that Firebase Hosting could deploy only the new or modified files? Wish no more! Because it's all here! Create multiple...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found