I'm trying to set up Firebase cloud functions, but when I input firebase init into terminal, it says:
You're about to initialize a Firebase project in this directory: /Users/username`.
How do I save the folder in my projects directory? I tried...
cd ~/Desktop/MyProject/
firebase init
But it didn't work. And Firebase documentation isn't very clear about this. All they say is this...
To initialize your project:
Run firebase login to log in via the browser and authenticate the
firebase tool.
Go to your Firebase project directory.
Run firebase
init functions.
Any ideas? I feel like I'm missing something simple.
Thanks.
I had the same problem. All you have to do is:
1) locate the firebase.json file in your /Users/username directory
2) delete that firebase.json file
3) Now run the firebase init command in your new project directory
This worked for me. Hope this helps.
I found this thread as I was having a problem initialising a firebase function directory. I am in directory D:/dir1/dir2 but whenever I ran "firebase init functions" it came up with:
You are about to initialise a firebase project in this directory: D:/
Found out there was a D:/firebase.json and D:/firebase.c from a previous bad install. Removed them and started the "firebase init functions" again to get the directory: D:/dir1/dir2
Reseting auth work for me. Here is the command
firebase login --reauth
Related
I experimented with firebase functions for the init part and it has created a folder for me. Now when I deploy each time it also picks up the functions folder. When I remove the functions folder I get an error, when deploying. How do I deploy everything but functions?
firebase deploy has a parameter --except . So to deploy everything except functions you can run:
firebase deploy --except functions
You can use the only option/flag, for example firebase deploy --only hosting,storage, see the CLI doc.
You can also use deploy targets which "are short-name identifiers (that you define yourself) for Firebase resources in your Firebase project".
Check to make sure that you have removed the implicit reference to the function in your index.js and then running firebase deploy should do the trick. If you want to explicitly delete the function completely, you can use the firebase functions:delete <myFunction> and then delete the functions folder. You can find more details in the doc here
so, im a newbie in programming and still learning some stuff (i use windows btw)
i try to make an app, connect it to firebase.
after setting up everything its time to setting the CLI
good news : i successfully setting up everything from node to nvm untill sucessfully launch the login in CLI.
bad news : right after successfully logn the CLI, im trying to type in the cmd
firebase deploy --only function
and this error appear
Error: not in a Firebase app directory (could not locate firebase.json)
i already search the web for the solution but i found nothing
can someone tell me did i miss something ?
thanks.
After logging into firebase with "firebase login" you will need to do: "firebase init" and then select the correct options when prompted. be sure to press the space bar to check the functions circle in the command line.
firebase init didn't work for me, but firebase init hosting did. You can read the firebase hosting initialization docs here.
firebase init
or
firebase init hosting
And then popup question:
Set up automatic builds and deploys with GitHub? No
I am using this tutorial, after I successfully login to Firebase, I need to set the root dir. So as the tutorial instructs, I run:
~/firebase-webchat$ firebase init --public .
However, I get the following error:
error: unknown option `--public'
Does anyone know what command I should be using?
Thanks
I`ve having the same issue, but i finally get a answer for me.
First of all, do you will net logout from your firbase cli login, so lets run:
$ firebase logout
So thats should logout you.
So next lets login again, but at this time, we will need accept the follow question from firebase cli.
$ firebase login --no-localhost
? Allow Firebase to collect anonymous CLI usage information? Yes
If the ask from firebase not appears, just run
$ firebase login --reauth --no-localhost
So before continue, lets make some improvement on our directory structure, put all your files inside directory called "public"
So to the GRAND FINALE, just run
$ firebase init
I hope help you.
Don't use firebase init --public . -> you're probably following the same tutorial I was. Just use firebase init. You'll get asked to set your public directory later.
=== 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? .
Hope that helped.
After updating Node JS, i was able to deploy the project.
You can try the same by updating Node JS:
sudo npm install npm#latest -g
Not sure but after updating the node.js, i was able to select project from terminal and able to deploy the project using this commands:
firebase deploy
You can set project from terminal too.
firebase deploy -project your-project-id
So I’m testing out the CLI today and firebase init with db/hosting selected, and choosing to create a new project, always says Error: Permission denied..
sudo firebase init didn’t help.
firebase-tools version 3.0.3 on OS X 10.11.5.
firebase init
You're about to initialize a Firebase project in this directory:
/Users/splaktar/Git/tmp
Before we get started, keep in mind:
* You are initializing in an existing Firebase project directory
? What Firebase CLI features do you want to setup for this folder? Database: Deploy Firebase Realtime Database Rules
=== 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.
? What Firebase project do you want to associate as default? [don't setup a default project]
=== Database Setup
Firebase Realtime Database Rules allow you to define how your data should be
structured and when your data can be read from and written to.
? What file should be used for Database Rules? database.rules.json
Error: Permission denied.
I've tried the answers here but they did not help. Is this just a bug in the firebase-tools?
I have the same issue and this is how I fixed it.
run firebase init
Deselect ❯◯ Database: Deploy Firebase Realtime Database Rules
Go through other steps to setup the initial app, selecting the default for each should work just fine.
run firebase serve
Hope that helps.
Sometimes it could happen when .firebaserc file exists.
Remove .firebaserc file and reattempt firebase init.
I was with the same problem, but I was not accessing the right account.
After accessed the right account, I created a new project and run "firebase list" (before this not happened) and my new project was there.
This solved my problem.
You need to have Owner or Editor IAM permission on the GCP project to use firebase init command.
The firebase init command initializes/enables the project to use Cloud Functions/Hosting etc for Firebase. Owners/Editors have higher permissions that allow APIs to be enabled etc.
it is a first-time task when you starting the development, and then init command can be avoided if you have set up your cloud functions code in VCS for multiple developers or you.
i.e, Usually after writing code, you will replicate the project to other developers, who will then also write code and use firebase use yourprojectid further.
It was successfully when deployed first time, now im trying to deploy again, shows an error:
Run firebase use default to activate project MY_APP_NAME
Error:
No project active, but a project alias is available.
When you select a project during firebase init, an alias called default is created for you. To create a new alias, run:
firebase use --add
Then Firebase CLI will ask you
Which project do you want to add? (Use arrow keys)
This command allows you to select a Firebase project and give it a named alias. Alias definitions are written to a .firebaserc file inside your project directory.
At first should firebase use to make default alias.
After firebase use default to use default.
Then firebase deploy yahoo.. you can deploy
If you run firebase use it should show you an interactive prompt to help you set the active project.
When this is run, it creates a mapping between the directory it was run in and which project / alias you selected, so if you moved the directory the firebase.json file is situated in the previous link may have been severed.
Use... firebase use project-ID......
Example:( firebase use rent-1234h)..after this
type firebase use
hope this will work
You may need to run commands firebase login and firebase init again before doing firebase deploy it solved problem in my case.
I also needed to update npm and node.
Please logout from firebase using terminal and try to login in again. This fixed the same issue I was facing.
Use following syntax,
firebase logout
firebase login
firebase use default
We are working with CircleCi and this is the way deployment command looks:
- run:
name: Deploy to Firebase
command: ./firebase deploy --token $FIREBASE_TOKEN --force --project production
Note the --project production flag , "production" is firebase project alias.
In my case firebase logout and login again by firebase login works.
I have the same problem - want to switch project alias to staging after pull my code repo to new machine. I have another project on firebase and logged in the same account as in this project, but error appears:
Error: No project active, but project aliases are available.
and
Error: Invalid project selection, please verify project staging exists
and you have access.
Verify that in .firebaserc file project alias exist and it tagets to correct project in your account.
In .firebaserc get your project name you want to build
Here I got 2 projects name, 1 default for dev env, 1 prod for production env
{
"projects": {
"default": {dev_project_name},
"prod": {production_project_name}
}
}
when you run firebase deploy add arg --project {project_name}
Deploy to production env
firebase deploy --only functions --project prod
Deploy to development env
firebase deploy --only functions --project default