Cannot deploy to Firebase due to .env file - firebase

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.

Related

Where to run gcloud init?

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.

Error while deploying environment variable to firebase

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.

Firebase deploy function --non-interactive

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.

Changing target Firebase ID using firebase-tools CLI

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.

Deployment with Password using Linux in Meteor?

How to deploy a app with password in meteor using linux. It's deploy good when with out set password.But i need to deploy app with password in meteor. I did but gets some error messages i didn't understand the following messages.So please see the below deployment process and suggestions me what to do?
[root#localhost myapp]# meteor deploy myapp.meteor.com --password
deploy: the --password option needs a value.
Try 'meteor help deploy' for help.
[root#localhost myapp]# meteor deploy myapp.meteor.com 123456
deploy: too many arguments.
Usage: meteor deploy <site> [--settings settings.json] [--debug] [--delete]
Deploys the project in your current directory to Meteor's servers.
You can deploy to any available name under 'meteor.com'
without any additional configuration, for example,
'myapp.meteor.com'. If you deploy to a custom domain, such as
'myapp.mydomain.com', then you'll also need to configure your domain's
DNS records. See the Meteor docs for details.
The --settings flag can be used to pass deploy-specific information to
the application. It will be available at runtime in Meteor.settings, but only
on the server. If the object contains a key named 'public', then
Meteor.settings.public will also be available on the client. The argument
is the name of a file containing the JSON data to use. The settings will
persist across deployments until you again specify a settings file. To
unset Meteor.settings, pass an empty settings file.
The --delete flag permanently removes a deployed application, including
all of its stored data.
Options:
--delete, -D permanently delete this deployment
--debug deploy in debug mode (don't minify, etc)
--settings set optional data for Meteor.settings
--star a star (tarball) to deploy instead of the current Meteor app
[root#localhost myapp]#
Perhaps you should use both command and option:
meteor deploy myapp.meteor.com --password 123456

Resources