Reputation: 281
When I am hosting my web page through firebase hosting then after writing command firebase deploy
I got the following error:
Microsoft Windows [Version 10.0.14393] (c) 2016 Microsoft Corporation. All rights reserved. C:\Users\amarg\Desktop\amar>firebase init ######## #### ######## ######## ######## ### ###### ######## ## ## ## ## ## ## ## ## ## ## ## ###### ## ######## ###### ######## ######### ###### ###### ## ## ## ## ## ## ## ## ## ## ## ## #### ## ## ######## ######## ## ## ###### ######## You're about to initialize a Firebase project in this directory: C:\Users\amarg\Desktop\amar Before we get started, keep in mind: * You are initializing in an existing Firebase project directory ? Are you ready to proceed? Yes ? What Firebase CLI features do you want to setup for this folder? Hosting: Configure and deploy Firebase Hosting sites === Project Setup First, let's associate this project directory with a Firebase project. You can create multiple project aliases by running firebase use --add, but for now we'll just set up a default project. i .firebaserc already has a default project, skipping === Hosting Setup Your public directory is the folder (relative to your project directory) that will contain Hosting assets to be uploaded with firebase deploy. If you have a build process for your assets, use your build's output directory. ? What do you want to use as your public directory? public ? Configure as a single-page app (rewrite all urls to /index.html)? No ? File public/404.html already exists. Overwrite? No i Skipping write of public/404.html ? File public/index.html already exists. Overwrite? No i Skipping write of public/index.html i Writing configuration info to firebase.json... i Writing project information to .firebaserc... + Firebase initialization complete! C:\Users\amarg\Desktop\amar>firebase deploy === Deploying to 'learningweb-6b2a3'... i deploying hosting + database: rules ready to deploy. i hosting: preparing public directory for upload... Error: An unexpected error has occurred. C:\Users\amarg\Desktop\amar>
Upvotes: 28
Views: 48362
Reputation: 532
In my case, I had two websites hosted in the same project. which requires appending the website ID along with the Firebase deploy command as follows.
firebase deploy --only hosting:your-website-name-in-firebase
Upvotes: 0
Reputation: 1
If it is throwing this error again and again "An unexpected error has occurred. [Reason: Requested entity already exists] in firebase console"
Then instead of doing anything simply restart your system.Then you will get to know it will automatically get registered.
Then click on your ProjectName and click on settings Icon and then you will get the option "See SDK Instructions". Go continue with these steps
Upvotes: 0
Reputation: 318
I'm not sure that this is the answer, but I think this happened to me because I was still running npm run dev
in another terminal when I did firebase deploy.
Upvotes: -2
Reputation: 1846
FWIW, I had this error while calling firebase deploy
from a wrong directory..
Upvotes: -2
Reputation: 11
In my case, this error occurred when I had not set the site name in firebase.json.
Upvotes: 1
Reputation: 847
Just check your firebase.json and remove unnecessary dependencies, check mine
{
"hosting": {
"public": "build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
Upvotes: 0
Reputation: 10502
firebase deploy
, firebase serve
, firebase ...
without any meaningful information in the firebase-debug.log
while using Cloud Functions for Firebase
?
Check out if you've package.json
in your functions
folder. It should have all dependencies from your root
's package.json
, and look somehow like this:
{
"name": "functions",
"description": "Cloud Functions for Firebase",
"engines": {
"node": "12"
},
"scripts": {
"serve": "firebase serve --only functions",
"shell": "firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"dependencies": {
"@angular-builders/custom-webpack": "^11.1.1",
"@angular/animations": "^11.2.7",
"@angular/cdk": "^11.2.6",
...
},
"private": true
}
devDependencies
aren't required.
Upvotes: 0
Reputation: 1
you should check if you have the folder of nodeJs and the folder of your website in the same local disk first!
I had the same problem, NodeJs was in local disk (D:)
and I was trying deploy from local disk (C:)
, but when I changed the folder of the website to (D:)
it worked fine.
Upvotes: 0
Reputation: 21
For me I tried a lot, then I figured out that firebase.json still has functions, I removed it and it worked By the way I was using
firebase deploy --except functions
firebase deploy --only hosting
That didn't help so maybe remove the ones that you don't need
{
*"functions": {
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint",
"npm --prefix \"$RESOURCE_DIR\" run build"
]
},*
"hosting": {
"public": "build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
]
}
}
Upvotes: 2
Reputation: 73
I was using Firebase functions in the past, I scrapped the idea and created what I wanted in node.js.
So, if you are not using firebase functions remove the following in firebase.json file
"functions": {
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint"
]
}
Upvotes: 2
Reputation: 29
In your firebase.json file, do you have a value set for functions or functions.source? If you do, that may be causing this issue. Remove the functions in angular.json it will work
Firebase document for functions
Upvotes: 1
Reputation: 48065
For me, it is because I run firebase deploy
inside functions
folder. I need to run it in the parent firebase
directory
Upvotes: 0
Reputation: 459
To solve this problem without restart,
firebase deploy --only functions
firebase --serve
Upvotes: 0
Reputation: 815
Make sure that you are logged in by running firebase login
in the terminal.
Upvotes: 3
Reputation: 7523
Below code fixed my issue.
Add below code into firebase.json.
{
"hosting": {
"public": "./",
"ignore": [
"firebase.json",
"database-rules.json",
"storage.rules",
"functions"
],
"headers": [{
"source" : "**/*.@(js|html)",
"headers" : [ {
"key" : "Cache-Control",
"value" : "max-age=0"
} ]
}]
}
}
Upvotes: 3
Reputation: 951
If you still are serving your site on localhost using firebase serve
it might cause problems. Shut it down then try the deploy. Worked for me.
Upvotes: 10
Reputation: 425
First of all, looking into firebase-debug.log
in the root of your project (next to firebase.json) might help to define the error. In my case there was "Cannot read property 'deploys' of undefined" error. There's an associated issue on github. Removing extra sites (I didn't actually need them) and leaving only the default one in the Firebase hosting dashboard solved my problem.
Upvotes: 13
Reputation: 374
Close the integrated terminal of your IDE by typing exit and hit enter, then re-open it and give the command firebase deploy
If the above option does not work then just use terminal in linux/mac and CMD in windows and navigate to the folder then give firebase deploy
command
Upvotes: 8
Reputation: 119
It could be due to npm and node version For mac os, you can update npm using command:
npm install -g npm@latest
and update node directly by going to link https://nodejs.org/en/ and download installer. and run
npm install -g firebase-tools
For removing firebase hosting deployment errors (also if you are updating existing hosted site)
you can do process again
1] firebase login
2] firebase init
3] firebase deploy
Make sure your current folder has two things: public folder (which contains all files index.html) And firebase.json file
Upvotes: 1
Reputation: 544
For me updating firebase-tools solved the issue
run below command in your cmd prompt
npm install -g firebase-tools
then try firebase init again
Upvotes: 31
Reputation: 133
I get that error when I haven't run npm install
. Try it out. I hope that simple solution helps anyone with the same problem.
Upvotes: 0
Reputation: 6007
In my case, resolve with:
firebase deploy --except functions
Upvotes: 6
Reputation: 1284
Yes I've faced this issue..
This is because of my node version I was using Node v.8.0.0
I just downgrade it to Node v.16.0.3
and then my deployment done :)
Upvotes: 1