Setting up Firebase CLI to use Functions - firebase

I am trying to update my Firebase CLI installation, in order to use the cloud functions for my project. I followed the getting-started guide, however for some reason, the CLI cannot detect the updated version.
I initialized a project of mine that I have already created via the Firebase console. During the project initialization, Firebase CLI mentioned that my CLI version should be updated, however the complete procedure went smoothly.
Once the initialization completed, I run for the first time (to update the CLI):
npm install -g firebase-tools
Once the updated finished, the command line reported:
firebase-tools#3.18.6
But when I run
firebase init functions
I get:
Error: CLI is out of date (on 3.0.1 , need at least 3.0.5)
I don't understand why this is happening, since the update reported that version 3.18.6 got installed Any hints would be great!
For reference, you can see a snapshot of the command line here.

It looks like you may have multiple versions of node installed in different locations. First, uninstall all versions of node that you may have previously installed. Make sure running node on the command line doesn't execute anything. Then, reinstall everything. After you've installed the Firebase CLI again, check its version with firebase --version.

Related

How to resolve Firebase emulator Node version warning?

What is the correct way to update Firebase Emulators after upgrading your local Node version?
After recently updating Node, the Firebase emulator throws the following warning when starting up:
Your requested "node" version "16" doesn't match your global version "18". Using node#18 from host.
The emulators still run without issue, but I'd like to prevent the warning going forward.
So far I've tried:
Deleting the yarn/package.lock file + node_modules
Then (re)running firebase init
Firebase docs: "This command starts a configuration wizard that lets you select emulators of interest, download the corresponding emulator binary files..."
Also suggested in this question
Then reinstalling the npm modules (i.e., yarn / npm -i)

CICD on GCP for Firebase Functions failing due to "replace /workspace/.runtimeconfig.json?" error

I have CICD for cloud functions as some of the functions require token (collection deletion), my pipeline takes care of that.
Since last release, the cloud build is failing to deploy functions as it's expecting some key press which can't be done during cloud build. The actual log error says the following:
"replace /workspace/.runtimeconfig.json? [y]es, [n]o, [A]ll, [N]one, [r]ename: NULL"
Locally I am able to run the Cloud Functions with Node 14, but on GCP I'm not able to find a fix for GCP Cloud Build.
**Note: **
I'm using latest packages as of today. firebase-tools package: 9.4.0
There are similar questions for deploying functions locally but none of them work for me as it's during Cloud Build. I'm using the guide here: https://cloud.google.com/build/docs/deploying-builds/deploy-firebase
https://github.com/firebase/firebase-tools/issues/3120
Firebase Functions deploy requires keyboard input in GCP
Well the answers on other links mentioned above were correct indeed. What I didn't realize was that Docker image of node during build takes the latest automatically. Thus, now it was taking Node 15.xx version.
To fix this, just update Node version in the cloudbuild.yaml. For example following during npm install on GCP:
- name: node:14
entrypoint: npm
waitFor: ['-']
id: 'npm-install'
dir: 'functions'
args: ['install']

Firebase CLI giving segmentation fault on Ubuntu

I'm having a hard time with firebase CLI,when I install it with npm, either locally in a projet or globally, and I call the command firebase it gives Segmentation fault with no further details.
I firs thought that the problem was with my version of Node since I was using 9.x, I moved back to 8.x versions, and reinstalled firebase with no success, I upgraded to 12.x, with no success too always same error.
I'm using NVM to handle my node versions properly, but still I can't find a fix for this problem.
nvm list gives this :
-> v8.11.3
v8.13.0
v12.3.0
system
When I run npm list firebase-tools it gives firebase-tools#7.9.0, I also tried uninstalling and reinstalling with no success .

Firebase Functions stopped Working and Can't deploy again

Firebase Cloud functions giving an error called.
Error: Server Error
The server encountered an error and could not complete your request.
Please try again in 30 seconds.
When I try to re-deploy, it gives following error.
Error setting up the execution environment for your function. Please try again after a few minutes.
What could be the reason? Is it following issue?
Sates: https://status.firebase.google.com/incident/Functions/18018
Yes there is an issue with Cloud Functions, as you can see from the link above
Investigating an issue with Functions
Incident began at 2018-03-09 03:30 (all times are US/Pacific).
Last update is this:
Mar 09, 2018 04:45
We are still investigating the issue with Cloud Functions execution. We will provide another status update as soon as possible.
https://status.firebase.google.com/incident/Functions/18018
After the issue is done, you will be able to deploy your functions again using the below:
firebase deploy --only functions
Edit:
I just deployed some functions and it is working now, just takes a bit of time.
I had the same issue and it was fixed after updating firebase-tools. I saw following on my console
Update available 7.0.0 → 7.8.1
Run npm i -g firebase-tools to update
Then i just changed node version and updated firebase tools
nvm use 11
npm upgrade firebase-tools -g
Sometimes switching environment will also help
firebase use dev
Sometimes when some node modules are not installed , the error you get will be like below
Deployment error.
Error setting up the execution environment for your function. Please try deploying again after a few minutes.
Make sure that all node modules are installed prior to deployment, I wasted almost 2 days and realised one node module was not installed .
I tried several different steps, including updating tools from firebase, using different node versions or dependencies on package.json. In the end, at firebase functions console, I cleared the log stack and tried to reach every deployment notification after executing firebase deploy. I found out one of my dependencies were moved from dependencies to devDependencies, which was causing
ERROR: (gcloud.beta.functions.deploy) OperationError: code=13, message=Error setting up the execution environment for your function. Please try again after a few minutes.
Solution:
Place back dependency on its place, moving from devDependencies into dependencies itself.
Update project dependencies with npm install
Re-deploy with firebase deploy

`firebase deploy` just hangs

I'm trying to deploy a site to firebase.
firebase init worked fine. I then ran firebase bootstrap and chose the tetris template. So far so good. But when I run firebase deploy I get Preparing to deploy Public Directory... and then it just hangs forever.
How can I figure out what's going wrong?
Random info in case it helps:
My firebase-tools is version 1.0.1; node is version 0.8.20; npm is version 1.4.23. I ran sudo npm install -g firebase-tools to get the CLI. I'm running on a debian chroot on Android 4.4.3 device. My wifi works fine. On a lark I even tried running sudo firebase deploy in case it depends on ICMP packets or something, but there was no difference.
Firstly, the main reason it's not working is that Node.js version 0.10 or greater is required.
However, even once you've upgraded Node (and I'd recommend getting the latest of firebase-tools too) you're likely to be attempting to deploy the directory that you ran the initial firebase init command from, or at least the folder you specified in the setup (which defaults to the folder you ran the command from).
You should change directory and run the firebase deploy command from the folder that was created by the bootstrap command - which would have been named after the name of the Firebase it was created with, and you can delete the firebase.json file created in the parent directory.
The reason is that firebase init and firebase bootstrap are two different ways of doing the same thing - getting a folder in a deployable state. firebase init is for existing projects with files that will eventually be deployed, and firebase bootstrap is for creating a project from one of the existing templates. By running both, the initial firebase init would have created a firebase.json file containing the settings specified by the prompts, and then the firebase bootstrap command would have created a whole new sub-folder with its own firebase.json for the different settings.

Resources