When I am triying to add environment variable to firebase, I have the following error when doing firebase deploy --only functions
Error: Cannot understand what targets to deploy. Check that you specified valid targets if you used the --only or --except flag. Otherwise, check your firebase.json to ensure that your project is initialized for the desired features
I can't understand why i have this error (I previously managed to add environment variable on the same project)
Note : I have also tried add environment variable to a newly created project so my firebase.json is not empty
Check that where you are running the command firebase deploy --only functions in command prompt is under the same directory as your functions folder.
Related
I have been doing firebase functions development for a while now and was used to be able to switch the target project from the command line via firebase use test, firebase use staging etc.
In my npm package scripts in the project I also invoke the firebase tools to do things like generating a .runtimeconfig.json via:
"scripts": {
"genruntime" : "firebase functions:config:get > .runtimeconfig.json",
}
In general, this worked fine - I'd change the target project from the command line, and the same target project would be used when I ran firebase commands by npm scripts.
Over the last few days though, I've found that sometimes the target projects weren't synced as I'd set the target environment to test but the find that the npm command was getting functions from the staging environment.
My firebase tools are the same version (global via project) and it's almost as if the target project is not being shared between the global firebase tools and the the npm ones.
Has anyone else seen this issue?
I can change my npm scripts to be explicit about the project being used but this has worked in the past and I'm curious about what might have happened.
When trying to deploy to Firebase (this case Firebase Functions) I'm getting this error:
Error: Failed to load environment variables from .env.:
- Error Key FIREBASE_TOKEN starts with a reserved prefix (X_GOOGLE_ FIREBASE_ EXT_)
error Command failed with exit code 2.
And I actually have an .env file in the functions directory.
And I need to keep the variable name because it's used in different parts of the application.
How do I solve this issue?
In this case, I need to have FIREBASE_TOKEN within my environment variables in a .env file because my development environment is within a Docker Container and I don't want to "firebase login" each time the container rebuilds.
So in order to deploy the solution I use dotenv and cross-var packages, and have the script like this:
"deploy": "dotenv -e ../.env cross-var firebase deploy --only functions --token %FIREBASE_TOKEN%",
What I did was to move the .env file to the upper level (root of the project) and reference it in the dotenv command with the -e flag to specify the location of the file.
Need to access some gcloud functions in a react project. Should I run gcloud init in the project root folder or within the firebase functions/ folder? Will it interfere with firebase deploy for the functions?
Following this: https://medium.com/#nedavniat/how-to-perform-and-schedule-firestore-backups-with-google-cloud-platform-and-nodejs-be44bbcd64ae
I already have some other firebase functions set up which I would deploy with firebase deploy --only functions. When I got to step 5 of the above tutorial, I got a gcloud command not found. I followed the instructions here: https://cloud.google.com/sdk/docs/#install_the_latest_cloud_tools_version_cloudsdk_current_version
and when it got to step 5 in that, I presume I should be doing it somewhere in the project folder to use that project's specific login? Without running it I get the following error when trying to use:
gcloud functions deploy backup --runtime nodejs8 --trigger-topic YOUR_TOPIC_NAME_HERE
ERROR: (gcloud.functions.deploy) Error parsing [name].
The [function] resource is not properly specified.
Failed to find attribute [project]. The attribute can be set in the following ways:
- provide the argument [--project] on the command line
- set the property [core/project]
The error message is clear. Add --project <project id> at the deploy command or perform a gcloud config set project <project id>.
If you use only firebase, firebase has automatically create a GCP project. Go to https://console.cloud.google.com to view your project name or ID. I think it's also possible to view this information in firebase console.
I am integrating CI/CD for deploying my firebase functions.
firebase use PROJECTID --token FIREBASE_TOKEN
firebase deploy --token FIREBASE_TOKEN --non-interactive
Now whenever a function is deleted from index.js, it throws the following exception.
Error: The following functions are found in your project but do not
exist in your local source code: httpSeeding(us-central1) Aborting
because deletion cannot proceed in non-interactive mode. To fix,
manually delete the functions by running: firebase functions:delete
httpSeeding --region us-central1
Is there a way in the non-interactive mode where a deleted functions are removed from the console without running firebase functions:delete httpSeeding??
Run deploy with -f option, it should delete extra functions in non-interactive mode
firebase deploy --token FIREBASE_TOKEN -f
From the docs available by running firebase help deploy, we see following option:
-f, --force delete Cloud Functions missing from the current working directory without confirmation
Just run the same deploy command from your shell. It will automatically delete functions that are missing from your source.
Also you can delete functions directly from the Cloud console.
At the command line...
When I run firebase deploy, I get the following error:
Error: The entered credentials were incorrect.
When I run firebase deploy --debug, I get the following (more detailed) error (and log) shown when you click here. (firebase-debug.log)
When I run firebase deploy --project good-project-id, I get the expected deployment behavior.
When I rerun firebase deploy and firebase deploy --debug I get the same errors already described.
How do I make the proper changes to eliminate the errors when running firebase deploy?
Notes:
I am running Mac OS/X Yosemite v10.10.5
I just ran the NPM installation procedure (via Homebrew) described here.
Look at the contents of your .firebaserc file in your project directory. You likely have a "default" project alias specified. Run firebase list and see if that project id shows up there as well (note it should be the project id, not the instance/subdomain name).
If it doesn't match, that's likely your issue. Another thing you can try is deleting the .firebaserc file and then running firebase use --add to create a new project alias.