47

Flutterfire just added a CLI for us to use, but I'm having a problem with the flutterfire configure command. I keep getting this error:

i Found 0 Firebase projects. Selecting project liveasy-1. FirebaseCommandException: An error occured on the Firebase CLI when attempting to run a command. COMMAND: firebase --version ERROR: The FlutterFire CLI currently requires the official Firebase CLI to also be installed, see https://firebase.google.com/docs/cli#install_the_firebase_cli for how to install it.

Even though I've installed the Firebase CLI and can run firebase --version without any issues. I installed the standalone binary and when that didn't work I installed it with npm as well. I can log in and see my projects list, but running flutterfire configure seems to be an issue. I can't also access any Firebase commands in Visual Studio Code.

Am I supposed to add something to the PATH in environmental variables? I've already added the cache/bin/ where flutterfire resides, but I don't know how to do the same for Firebase.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Nana Kwame
  • 942
  • 1
  • 6
  • 21

24 Answers24

73

I went through the same issue on Windows. I figured out that installing Firebase CLI using the binary file didn't work for me (even after Ventosus' answer), so here is my answer.

I had to install the Firebase CLI using the npm command (Node.js is required to use this command):

npm install -g firebase-tools

I've then been able to run the command: flutterfire configure

Here is the documentation you have to follow in case you don't have Node.js or if you need any information: Firebase CLI documentation

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Julien J
  • 2,826
  • 2
  • 25
  • 28
51

Run:

firebase logout 

Then:

firebase login 

The issue is that your token expired.

DeePanShu
  • 1,236
  • 10
  • 23
25

For solving the standalone issue part of your question:

1 copy the downloaded .exe to your flutter project folder

2 rename it from firebase-tools-instant-win to just firebase (exe)

3 run "firebase login" from cmd line in the folder where you put the .exe and continue with flutterfire configure

This is a quick setup for a single project. If you plan to use Firebase CLI across multiple projects, you need to rename and move the .exe to a suitable location and fix environment/paths issues.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Ventosus
  • 359
  • 1
  • 4
  • 9
  • 1
    yes i did, and i had same issues as you had, i solve it in 45 seconds using above method. put the standalone in your flutter project folder, rename the standalone and flutterfire config will work – Ventosus Dec 20 '21 at 11:35
  • 1
    I did the above three steps and still getting the same error, I have logged in to the Firebase by downloading standalone using npm. My projects list shown in npm command but "flutterfire configure" didnt work. Any help will highly be appreciated. – K_Chandio Dec 30 '21 at 09:25
  • the NPM is not the standalone they are referring to as well as the one i describe above.. the standalone is a the one found on the download page (look for: Download the Firebase CLI binary for Windows.) its a .exe fille named: firebase-tools-instant-win.exe which you could rename to firebase.exe and put it in your flutter project folder as described in my answer – Ventosus Dec 30 '21 at 14:02
  • 1
    I did, followed all three steps, renamed CLI binary to firebase.exe, but I wasn't able to run flutterfire configure command... – K_Chandio Dec 30 '21 at 15:33
  • ok, that's strange.. worked for me.. did it twice now.. not sure exactly why that is. and you put it in your flutter project folder right? ran flutterfire command from same folder? – Ventosus Dec 30 '21 at 16:44
  • I did everything right but don't know what's the problem, I just solved the problem by Creating FirebaseOptions file and write code for that and added project in firebase console manually and it works. (You can copy FirebaseOptions file from a project where CLI worked and added that file in project and change credentials according to your project) – K_Chandio Jan 05 '22 at 19:09
  • This worked but for some strange reason firebase configure doesnt work instead firebase config works – Dylan Karimagoko Apr 26 '22 at 13:25
7

For macOS users:

Enter dart pub global activate flutterfire_cli on your terminal.

It will successfully install flutterfire_cli, but with the warning:

The solution is to update the environment path.

Open terminal.

  1. vim ~/.zshrc

  2. Press the I key to activate insert mode.

  3. Add -- export PATH="$PATH":"$HOME/.pub-cache/bin"

  4. Press Esc then write :wq in the terminal and press enter to exit Vim.

  5. Reopen the terminal and check flutterfire --version

  6. firebase login

  7. flutterfire configure

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Jiten Basnet
  • 1,623
  • 15
  • 31
5

Download the standalone binary for the CLI for Windows. It will download an executable, firebase-tools-instant-win.exe.

Copy it into your preferred location

The important part is to enter the path where the executable resides in the Environment variables:

Environment variablesSystem variablesPathNew → Enter the path

Launch the file and enter the necessary commands.

firebase login

dart pub global activate flutterfire_cli

cd [your project directory]
flutterfire configure
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Kay Garr
  • 51
  • 1
  • 2
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 21 '22 at 09:05
  • It is still showing ``` i Found 0 Firebase projects. FirebaseCommandException: An error occured on the Firebase CLI when attempting to run a command. COMMAND: firebase --version ERROR: The FlutterFire CLI currently requires the official Firebase CLI to also be installed, see https://firebase.google.com/docs/cli#install_the_firebase_cli for how to install it. ``` – Shrirang Mahajan Sep 17 '22 at 01:05
4

It's fixed with me just by running the command:

"firebase login --reauth"

If your (Firebase debug log) contains a 401 error, then it just needs to be reauthorized.

To make sure that the this is the problem, run:

firebase projects:list and it will give you an error! then the solution is to reauthorize by the command above.

See: How do I solve: Error: Failed to list Firebase projects. See firebase-debug.log for more info

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Fuaad
  • 41
  • 2
3

For Windows users, make two CLI installations

Firebase CLI reference, Windows

  1. Windows installation. It has a GUI, which is good

  2. npm installation - for the FlutterFire module to be recognized:

    npm install -g firebase-tools

Do not use Bash. Use the cmd to execute FlutterFire commands.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Mark Dionnie
  • 305
  • 4
  • 11
  • 1
    when i try to run the windows version i get this error SyntaxError: Unexpected end of JSON input at JSON.parse () at ChildProcess. (C:\snapshot\firepit\welcome.js:115:27) at ChildProcess.emit (node:events:527:28) at maybeClose (node:internal/child_process:1092:16) at Socket. (node:internal/child_process:451:11) at Socket.emit (node:events:527:28) at Pipe. (node:net:709:12) – David Aug 23 '22 at 12:41
  • This is the only thing that worked for me. – Ojonugwa Jude Ochalifu Nov 02 '22 at 06:26
1

In case you run into another problem, especially this

Unhandled exception:
FormatException: Unexpected character (at character 1)...

After Ventosus' answer, check this GitHub issue out. It helped me solve this issue.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Quwaysim
  • 351
  • 3
  • 11
0

I had the same issue and tried everything I could. but npm method worked really well. Install nodejs from https://nodejs.org/en/

this will also install npm to your system. then just run the command npm install -g firebase-tools

and you are good to use all firebase functions

All information I told I gained it from documentation. Developers best friend

0

For me it was that my authentication token was expired. As @DeePanShu pointed out, you should do

firebase logout && firebase login

But, if that's not the case, I highly recommend to read the file generated when the error happens (it will be saved in your app folder). There's a description of the problem, so you can avoid trying out solutions without knowing the actual problem.

Andres Eloy
  • 113
  • 1
  • 7
0

The only thing that helped me on Windows was just to use Android Studio's built-in terminal.

PowerShell and the Firebase EXE file both throw different errors and wouldn't work.

I also used all the solutions mentioned here and there without any luck.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Konstantin Kozirev
  • 944
  • 1
  • 10
  • 23
0

I tried to use the binary file from the official CLI website which is firebase-tool-instant-win.exe and naming it firebase.exe.

And then putting it in the Flutter project file that I am working on. It seems to do the trick.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 17 '22 at 15:03
0

If you have installed Firebase CLI with npm and still getting the error, try to restart your system and then try running the commands.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
samir
  • 1
0

Make sure that you are using the same Gmail account, signed in Firebase CLI and Firebase console.

Then Relogin into the Firebase CLI

  1. Firebase logout

  2. Firebase login

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
0

For me, it works only in the command prompt (not PowerShell or the Node.js runtime): Microsoft Windows

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Unais IB
  • 69
  • 3
0

I had the same problem.

In my case, it was the Node.js version. Try to do: firebase --version and if you have this message:

Firebase CLI v11.17.0 is incompatible with Node.js v12.14.0 Please upgrade Node.js to version ^14.18.0 || >=16.4.0

Just upgrade your Node.js version.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
A Tariq
  • 51
  • 1
  • 4
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 15 '22 at 20:57
0

The binary file didn't work for me either. But I found another way that worked for me.

  1. Go to the project's root.
  2. Open the Command prompt.
  3. Run npm install -g firebase-tools. (Make sure Node.js is installed)
  4. There may be a couple of WARN deprecations, but never mind.
  5. Then run flutterfire configure
  6. You will be asked to select the project and the mobile versions you are willing to build.
  7. Then make sure that a file was generated in 'lib\firebase_options.dart'

See the link for the image

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
0

I have tried all of the other answers, but there is the one solution that worked which makes sense (I'm so disappointed that I've forgotten about this).

My Flutter project path was inside of folders with symbols/spaces/uppercases in the name, once I've changed it, it worked.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Kream
  • 131
  • 1
  • 3
  • 12
0

For a Mac, run flutterfire configure as a superuser, hence run sudo flutterfire configure in the terminal without quotes.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
0

The Problem:

Flutter Cli needs two CLI supports (FlutterFire and Firebase), but here only FlutterFire is installed and added to your environment configuration. Firebase also needs Firebase cli.

The Solution:

The solution is to add C:\Users<username>\AppData\Roaming\npm. This path in your environment configuration, and then restart your cmd, PowerShell, or Visual Studio Code.

By this, you will let your system know that here is an executable file, which should run globally on your machine.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • 3
    Why are you commenting on your own answer like this? Did you mean to do it from a different account? – DavidW Jul 11 '23 at 10:03
0

In my case, it was a case of having a short name. I wanted to create a project with the name kwss. This did not go through, but on changing the name to something else like hello_world, this worked and did not get the error again.

I'm not saying this is the solution, but it might work for someone's case.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Kibiku Brian
  • 221
  • 2
  • 11
0

I had exactly same issue

The solution that worked for me:

  1. copy 'firebase-tools-instant-win.exe'. paste into your flutter project file, rename to 'firebase'.
  2. run 'flutterfire configure' on the command line (others had error).

Hope this helps

0

What worked for me was to enable scripts to run by setting the PowerShell execution policy as this was preventing me from running scripts.

Open PowerShell as an administrator Run the command: Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

0

Do not waste your time by login/logout. It happens when your project limits have been reached. Add new accounts, and deleting projects will require 30 days to get effective. So the best solution is to add a new account but log out current account.