Firebase: error: unknown option `--public' - unix

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

Related

Firebase trouble when initializing CLI to deploy a react app

I keep getting the error below:
? Are you ready to proceed? Yes
? Which Firebase features do you want to set up for this directory? Press Space to select features, then Enter to confirm your choices. Hosting: Configure files for Firebase Hosting and (optionally) set up GitHub Action deploys
=== 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.
? Please select an option: Use an existing project
Error: Failed to list Firebase projects. See firebase-debug.log for more info.
PS C:\Users\xxxxxlinked-in>
I have tried everything I can find on StackOverflow:
firebase login will log me in.
I have also done the firebase login --reauth one and also just reinstalling it npm install -g firebase-tools.
Its just when I go to use an existing project.
If it helps to know, I keep gettin another error when uing this command firebase projects:list.

New project not showing on firebase CLI

I have recently had an issue with my firebase account where any new projects don't show in the CLI when I run firebase init. I deleted a project I didn't need, and that updated immediately, any help is greatly appreciated!
There is a simpler solution, first, determine your projectId from the Firebase Console. Firebase usually adds a random number to your project's name i.e if you are using demo as the project name the projectId will look like demo-1234
Next, in your terminal, cd into your project's target directory and issue the followoing command
firebase -P <projectId> init
assuming demo-1234 was my projectId, I will issue the command as below
firebase -P demo-1234 init
Use firebase use --add projectId, this will add your project
Yea this is a weird one.
Use the [don't setup a default project] option
then, as mentioned by #Dragon, use firebase use --add projectId to add the project
I did
firebase logout
then
firebase login
It works for me
The quickest way to do when initializing is by using the --project option:
firebase init --project <projectId>
The below solution worked for me.
Get the Project Id from firebase console. e.g. myproject-2233
On Firebase CLI run below command
$ firebase -P myproject-2233
Next Select the features you want to add e.g. Web Hosting
Next Select "Don't Setup a default project"
Give the public folder name
It worked only after choosing "Don't Setup a default project"
##
Check with firebase login.
You will get redirected to browser and just do sign in.
then firebase -P <Project-ID> init
Then follow all options that come along.
"Which Firebase CLI features do you want to set up for this folder?" Choose "Hosting: Configure and deploy Firebase Hosting sites."
"Select a default Firebase project for this directory:" Choose the project you created on the Firebase website.
"What do you want to use as your public directory?" Enter "build".
Configure as a single-page app (rewrite all urls to /index.html)?" Enter "Yes".
"File build/index.html already exists. Overwrite?" Enter "No".
For me, turns out I was logged into the Firebase CLI using a different account from the one that created the project. The solution was either to log into the CLI with the account that created the project with:
firebase login
or, using the Firebase console, invite the user who's logged into the CLI
Just do a refresh in your firebase console, sometimes the firebase auth token is expired. I had the same issue and after refreshing it fixed for me.

Set Firebase init Directory for cloud functions

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

How to update a file that I deployed to Firebase Hosting?

On deploying my app to Firebase, I am getting this message:
You're seeing this because you've successfully setup Firebase Hosting. Now it's time to go build something extraordinary!
I learnt from a previous post that I need to replace the default index.html with my custom index.html. How do I do that using the Firebase Console?
You cannot change hosted files in the Firebase Console.
Instead, you should change the index.html on your local copy where you initially ran the firebase deploy command. Once you're done with the changes, run firebase deploy again to push the updated version of your website to Firebase Hosting.
For small changes it is probably faster to run firebase serve. This spins up a local web server, so that you can test the changes. Once you're satisfied they work, publish them to Firebase Hosting with firebase deploy again.
Update: this is now possible through some custom scripting. See my answer here for details: Upload single file to firebase hosting via CLI or other without deleting existing ones?
Simply make the changes you want to and then type
npm run build
After this spin the server again using
firebase deploy
The changes you want will be updated.
You can also see the updated changes with the command
firebase serve
and then run firebase deploy when you're satisfied.
First of all Update all the coding and assets files in your local system then,
1) Go to the directory in the terminal by typing $ cd {add your directory}
2) Login on your terminal console by typing $ firebase login in the terminal
3) after login write $ firebase deploy
then, go to Hosting Section in your Firebase Console and delete the previously deployed files by deleting the previously added section in {Poject_Name} release history,
like this
enter image description here
Its a simple solution. This message is caused by the index.html file in your public folder being replaced with the index.html file provided by firebase.
All you have to do is navigate to the directory of your web app folder on your terminal and type in
$ rm .firebaserc
then
$ firebase init
after you've completed the firebase initialization, replace the new index.html file with the one inside the public folder and then type
$ firebase deploy

Firebase "Run firebase use default to activate project APP_NAME"

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

Resources