简体   繁体   中英

FirebaseCommandException: An error occured on the Firebase CLI when attempting to run a command

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 with no issues. I installed the standalone binary and when that didn't work I installed it with npm as well. I can login and see my projects list but running flutterfire configure seems to be an issue. I can't also access any firebase commands in vscode.

I'm 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.

I passed 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

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 env/paths issues.

Run:

firebase logout 

Then:

firebase login 

The issue is that your token expired.

For Windows Users, Make 2 CLI Installations

https://firebase.google.com/docs/cli#install-cli-windows

  1. Windows Installation - it has gui, which is good
  2. npm installation - for the flutterfire to be recognized - npm install -g firebase-tools

Do not use bash, use the cmd to execute flutterfire commands.

for macOS user:

Enter dart pub global activate flutterfire_cli on your terminal.

It will successfully install the fluterfire_cli but with the warning:

The solution is to update the environment path.

Open terminal.

  1. vim.zshrc

  2. Press "i" key to activate insert mode.

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

  4. Press "Esc" then write:wq in terminal and press enter to exit vim.

  5. Reopen the terminal and check "flutterfire --version"

  6. firebase login

  7. flutterfire configure

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.

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

"firebase login --reauth"

if your (firebase debug log) contains 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: https://stackoverflow-com.translate.goog/q/57941289?_x_tr_sl=en&_x_tr_tl=ar&_x_tr_hl=ar&_x_tr_pto=sc

Download the standalone binary for the CLI for windows

It will download an executable firebase-tools-instant-win.exe

Copy into your preferred location

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

Environment variables -> System variables -> Path -> new -> Enter the path

Launch the file and enter the necessary commands.

firebase login

dart pub global activate flutterfire_cli

[your project directory]$ flutterfire configure

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.

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

The only thing helped me on Windows is just to use Android Studio's built-in terminal. Powershell and firebase exe both throw different errors and won't work. I also used all the solutions mentioned here and there with no luck.

None of the above helped. Re-downloading the firebase.exe binary and placing it in the flutter project solved it for me. I didn't need to rename it.

Hello guys I tried to use the binary file from the official CLI website which is firebase-tool-instant-win.exe and naming it firebase.exe , then putting it in the flutter project file that I am working on, seems to do the trick

if you have installed firebase CLI with npm and still getting the error. Try to restart your system and then try running the commands

Make sure that you are using same gmail account, signed in firebase cli and firebase console.

Then Relogin into the firebase cli

1.firebase logout

2.firebase login

For me, it works only in command prompt(not PowerShell or node js runtime): ms windows

I had the same problem. In my case, it was the nodeJs version. Try to do: firebase --version, & 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 version.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM