Reputation: 49
I'm using firebase hosting and when I try to deploy my project, I get the following error:
The firebase log says the following:
[debug] [2020-05-03T14:31:51.377Z] TypeError: Cannot read property 'deploys' of undefined at C:\Users\albert.valeta\AppData\Roaming\npm\node_modules\firebase-tools\lib\deploy\index.js:84:36 at process._tickCallback (internal/process/next_tick.js:68:7)
The command I'm using is:
firebase deploy --only hosting:last-call-manager-pre
The firebase.json is:
{
"hosting": {
"public": "build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
The weird thing is that when I add the site property to the firebase.json is doesn't throw any error and completes the deploy. That firebase.json looks like:
{
"hosting": {
"site": "last-call-manager-pre",
"public": "build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
I care about the error because I have 2 different environments and I don't want to modify the firebase.json file everytime I want to deploy for each targetted environment. Besides, I don't know exactly the meaning of this site attribite and didn't found too much information about it.
Could someone help me solve this issue?
Upvotes: 0
Views: 558
Reputation: 2741
Let's say I have a project where I have 2 environments ( test + prod) that are located in 2 different Firebase projects. Each firebase project contains multiple apps so I also need to specify which app to deploy to, in each project.
Firebase project name for test is "firebase-app-test"
Firebase project name for prod is "firebase-app-prod"
App name in the test Firebase project is "app-test"
App name in the prod Firebase project is "app-prod"
firebase.json looks like this:
{
"hosting": [
{
"target": "test",
"public": "dist",
... rest of settings for test project
},
{
"target": "production",
"public": "dist",
... rest of settings for prod project
}
]
}
.firebaserc then looks like:
{
"projects": {
"default": "firebase-project-test",
"test": "firebase-project-test",
"production": "firebase-project-prod"
},
"targets": {
"firebase-project-prod": {
"hosting": {
"production": [
"app-prod"
]
}
},
"firebase-project-test": {
"hosting": {
"test": [
"app-test"
]
}
}
}
}
Deploy the test app to the firebase-project-test:
firebase deploy --only hosting:test --project test
Deploy the prod app to the firebase-project-prod
firebase deploy --only hosting:production --project production
Upvotes: 0