I'm using the firebase-tools CLI to deploy firebase functions. I'm trying to deploy a function using firebase deploy --only functions:functionName.
This is in an existing project. The functions are located in /functions/index.js.
Up until a few hours ago, deploying worked fine. But now when trying to deploy a new function I get the following:
i deploying functions
i functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i functions: ensuring required API cloudbuild.googleapis.com is enabled...
+ functions: required API cloudbuild.googleapis.com is enabled
+ functions: required API cloudfunctions.googleapis.com is enabled
i functions: preparing functions directory for uploading...
+ Deploy complete!
But it clearly does not even upload anything or deploy a function. Trying to deploy an existing function, I get The following functions are found in your project but do not exist in your local source code:
I'm a bit baffled as to how this seems to have "broken". Even looking at the git for the project there have been no changes to any config files or anything, other than writing a new function. I have not updated any packages since last deploying, and have tried the previous version of firebase-tools as well as the latest version.
Deploying a different function to a different project in the same manner is successful.
Turns out, I had created a file called functions.js in the project root directory (not /functions directory) and it appears firebase-tools was looking to that (empty) file for its functions, instead of the functions directory. Strange, and no kind of error message since I guess the file it thought it was looking for did exist.
Related
I have deployed Firebase functions in the past many times. For some reasons, recently (around 2-3 days) I am frequently getting error while deployment. I am using windows to release the code. When I tried with setting up the same project in my Linux system and Mac system the deployment works correctly. What may be the issue for the release from Windows environment.
The following is the issues getting while deployment.
! functions[payment(us-central1)]: Deployment error.
Function failed on loading user code. This is likely due to a bug in the user code. Error message: Error: please examine your function logs to see the error cause: https://cloud.google.com/functions/docs/monitoring/logging#viewing_logs. Additional troubleshooting documentation can be found at https://cloud.google.com/functions/docs/troubleshooting#logging. Please visit https://cloud.google.com/functions/docs/troubleshooting for in-depth troubleshooting documentation.
Functions deploy had errors with the following functions:
admin
cancellation
cost
createStripeCharge
customer
driver
driverLiveTracking
generalSettings
notification
order
payment
To try redeploying those functions, run:
firebase deploy --only "functions:admin,functions:cancellation,functions:cost,functions:createStripeCharge,functions:customer,functions:driver,functions:driverLiveTracking,functions:generalSettings,functions:notification,functions:order,functions:payment"
To continue deploying other features (such as database), run:
firebase deploy --except functions
Error: Functions did not deploy properly.
Following is the deployment command I am using for
"echo Deploying Functions && npm run lint && npm run build && firebase deploy --only functions"
Please share your knowledge over the issue.
Thanks.
I have resolved this issue. On building, I found that the node modules and lib functions are not replacing correctly with the new build. I have done a name changing previously and that are not reflecting in the new build.
Steps followed:
Removed node modules and lib files
Npm install
Npm run serve
And a new build is worked fine as well. I got the same issue using Jenkins build also. I just manually removed the same in server also.
You can find the issue by examining the actual logs. view them using this command
firebase functions:log
The specific issue will be visible there. I sometimes had error as simple as a missing packages in package.json
I have some troubles deploying a Nuxt 2.4 application on Firebase.
I tried these 2 tutorials but they seem outdated:
https://www.youtube.com/watch?v=ZYUWsjUxxUQ
https://github.com/davidroyer/nuxt2-ssr-firebase
With the first tutorial, I could make my app working on local (after few hours and with a lot of modifications for babel integration) but I never could serve or deploy it. I thought the tutorial was old and manipulations can't be exactly done like the guy did.
With the second tutorial, I cloned the repository to try to deploy the example. I had to change 2 things : install Node 8 instead of Node 10 and upgrading firebase-admin to the last version in prod/server dir. Here is what I got:
npm run setup is ok
npm run dev is ok and the project works fine
npm run build is ok
npm run serve fails.
First I got this error :
The Cloud Functions emulator requires the module "firebase-admin" to be version >7.0.0 so your version is too old. You can probably fix this by running "npm install firebase-admin#latest" in your functions directory.
Indeed, the version configured in package.json is the 5.13. I did the update from the prod/server dir, and I get the 8.0.0.
And then I got a different error about gRPC :
Error: Failed to load gRPC binary module because it was not installed for the current system
Expected directory: node-v57-darwin-x64-unknown
Found: [node-v64-darwin-x64-unknown]
This problem can often be fixed by running "npm rebuild" on the current system
I tried npm rebuild as mentionned, without success.
npm run deploy fails.
I get this trace:
i deploying functions, hosting
i functions: ensuring necessary APIs are enabled...
✔ functions: all necessary APIs are enabled
i functions: preparing prod/server directory for uploading...
Error: Error parsing triggers: Cannot find module 'acorn'
Try running "npm install" in your functions directory before deploying.
Of course, I tried the npm install from prod/server dir, but nothing changed.
Is there somewhere i can find a tutorial that can help me deploy my SSR app to firebase ? Thanks in avdance !
EDIT 1 :
After a few modifications on my package.json
upgrading firebase-functions and express to the latest versions
downgrading firebase-admin to the 7.0.0 version
adding acorn
I can serve and deploy but I get a "504 gateway time-out" webpage when I call the URL....
Have you tried to run npm install grpc inside functions folder?
I am building an "actions on google" application with firebase hosting the node.js back-end.
First deployment was successful and provided a webhook which works fine.
After updating my .js files I run:
firebase deploy --only functions
and get the following output:
=== Deploying to 'monprogrammetele-c5169'...
i deploying functions
i functions: ensuring necessary APIs are enabled...
✔ functions: all necessary APIs are enabled
i functions: preparing functions directory for uploading...
✔ Deploy complete!
Project Console: https://console.firebase.google.com/project/monprogrammetele-c5169/overview
Everything looks fine except that when I test with the simulator
https://console.actions.google.com/project/......
I still get the old version running....
The only difference I can see between the initial deploy and this one is that firebase is not providing a webhook link like it did the first time:
Function URL: https://us-central1-programmetele-82c89.cloudfunctions.net/teleProgram
I have assumed it is still the same.
The missing URL during deployment was fixed in version 3.16.0 of the CLI. Please upgrade it like this:
npm install -g firebase-tools
Issue was on my side, did some changes on index.js for local testing that were incompatible with firebase. I would suggest though that firebase is more explicit in its debugging messages.
Thanks for the help,
Thierry
I'm in the process of uploading some Cloud Functions for Firebase via the Firebase CLI. I have my functions folder setup and everything is correct. :I actually use this exact functions folder in another project but for whatever reason in this particular project, when I run firebase deploy --only functions, I get this:
i deploying functions
i functions: ensuring necessary APIs are enabled...
i runtimeconfig: ensuring necessary APIs are enabled...
✔ runtimeconfig: all necessary APIs are enabled
✔ functions: all necessary APIs are enabled
i functions: preparing functions directory for uploading...
i functions: packaged functions (972 B) for uploading
✔ functions: functions folder uploaded successfully
i starting release process (may take several minutes)...
i functions: updating function getUserByEmail...
⚠ functions[getUserByEmail]: Deploy Error: Failed to initialize a region
Functions deploy had errors. To continue deploying other features (such as database), run:
firebase deploy --except functions
Error: Functions did not deploy properly.
Does anyone know what this error means?
Thanks in advance!
I'm having trouble doing firebase deploy --only functions for an app on Blaze plan.
I have the latest firebase-tools CLI (v 3.5.0).
I get the following error:
=== Deploying to 'myapp1234'...
i deploying functions
i functions: ensuring necessary APIs are enabled...
i runtimeconfig: ensuring necessary APIs are enabled...
✔ runtimeconfig: all necessary APIs are enabled
✔ functions: all necessary APIs are enabled
i functions: preparing functions directory for uploading...
i functions: packaged functions (1.29 KB) for uploading
✔ functions: functions folder uploaded successfully
i starting release process (may take several minutes)...
i functions: updating function myFunc...
⚠ functions[myFunc]: Deploy Error: Failed to initialize a region
Functions deploy had errors. To continue deploying other features (such as database), run:
firebase deploy --except functions
Error: Functions did not deploy properly.
I've retried this every half hour for the past 12 hours, thinking there's an outage. The firebase status page shows all green.
Ok, here's what I found, a little weird:
firebase list shows all the firebase projects you have access to, BUT they are not already available (i.e. added as alias to your current folder project).
Even if the firebase-tools CLI allows you to do firebase deploy --project myproject1, if you do not have myproject1 declared in .firebaserc => it will fail with the weird region error above.
To fix this, I found that there are 2 options:
firebase use --add (will trigger an interactive list)
firebase use myproject1
=> and then firebase deploy --project myproject1 will work (with or without the optional --only functions)