6

I'm having a problem to configure Flutter Fire to my project. I installed using npm install -g firebase-tools --force and then I tried > dart pub global activate flutterfire_cli but i still have a problem with CLI. I can login and see the version but i can't run flutterfire configure

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.


After read all the topics on stackoverflow and on internet i can't solve my problem, any ideas? Running npm install -g firebase-tools I got this:

>  npm install -g firebase-tools
C:\Users\loveh\.cache\firebase\tools\firebase -> C:\Users\loveh\.cache\firebase\tools\node_modules\firebase-tools\lib\bin\firebase.js
+ [email protected]
updated 1 package in 11.091s

Now it's appearing this error:

⠋ Fetching available Firebase projects...
Unhandled exception:
FormatException: Unexpected character (at character 1)
#
^

#0      _ChunkedJsonParser.fail (dart:convert-patch/convert_patch.dart:1383:5)
#1      _ChunkedJsonParser.parseNumber (dart:convert-patch/convert_patch.dart:1250:9)
#2      _ChunkedJsonParser.parse (dart:convert-patch/convert_patch.dart:915:22)
#3      _parseJson (dart:convert-patch/convert_patch.dart:35:10)
#4      JsonDecoder.convert (dart:convert/json.dart:612:36)
#5      runFirebaseCommand (package:flutterfire_cli/src/firebase.dart:95:25)
<asynchronous suspension>
#6      getProjects (package:flutterfire_cli/src/firebase.dart:114:7)
<asynchronous suspension>
#7      ConfigCommand._selectFirebaseProject (package:flutterfire_cli/src/commands/config.dart:264:24)
<asynchronous suspension>
#8      ConfigCommand.run (package:flutterfire_cli/src/commands/config.dart:351:37)
<asynchronous suspension>
#9      CommandRunner.runCommand (package:args/command_runner.dart:209:13)
<asynchronous suspension>
#10     main (file:///C:/Users/loveh/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutterfire_cli-0.2.2+2/bin/flutterfire.dart:57:5)
<asynchronous suspension>

News

 npm install -g firebase-tools
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm WARN deprecated [email protected]: this library is no longer supported
npm WARN deprecated [email protected]: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/d
ebug/issues/797)
npm WARN deprecated [email protected]: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142

changed 691 packages, and audited 692 packages in 36s

38 packages are looking for funding
  run `npm fund` for details

25 vulnerabilities (15 moderate, 10 high)

To address issues that do not require attention, run:
  npm audit fix

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.

32
  • Are you able to run this without --force npm install -g firebase-tools --force ? There should be an error log generated, please share that. I assume you already tried firebase logout and firebase login? Commented Jun 2, 2022 at 21:08
  • I will edit the post with the error log. Yes i've tried logout and login :c Commented Jun 2, 2022 at 21:16
  • No error log generated Commented Jun 2, 2022 at 21:20
  • What does firebase --version give you? Commented Jun 2, 2022 at 21:32
  • it gives me 11.0.1 Commented Jun 2, 2022 at 21:33

9 Answers 9

3

Remove the previously installed firebase.exe and rely on firebase installed via npm install -g firebase-tools only.

The problem resulted from conflicting installations.

Sign up to request clarification or add additional context in comments.

1 Comment

this is the path for windows users C:\Users\user_name\AppData\Roaming\npm\ delete firebase files -> update node js -> reinstall firebase tools by the above command, and start flutter fire cli again :)
2

If you get the FormatException: Unexpected character (at character 1) error, look if you have a firebase.exe file in your flutter main folder. This was my problem. After deleting the file, flutterfire configure works with no problem.

Clarification: I have added the firebase-cli binary (firebase-tools-instant-win.exe) to the main folder of my flutter project and renamed it to firebase.exe because of previuos bug fix attempts. If you don't have done that, there should be no firebase binary in your flutter main folder.

Comments

2

Resolved for me by doing the following after struggling with plenty of errors

  1. Use nvm to install latest node
  2. Change the default directory for packages on windows pc using prefix command. For me I created directory here %appdata%.npm-global and go to this directory then use prefix command to set the default for npm global packages
  3. Ensure this path is in your windows PATH
  4. Install firebase tools npm install -g firebase-tools
  5. Install flutterfire cli dart pub global activate flutterfire_cli
  6. cd to my flutter app directory
  7. From command prompt firebase login
  8. type flutterfire configure

Ensure you do not have the windows exe downloaded as it may conflict when you run firebase/flutterfire. For me, the trick was to ensure I used nvm to install npm, setting default directory install for npm global to something other than default. I believe this was a permission issue.

Comments

2

Solution 2023 for Windows 11

  1. Download stand-alone binary Firebase CLI executable (firebase-tool-instant-win.exe) to "Downloads" folder
  2. Run the executable from Downloads. Do not move it or rename it, this makes it unhappy for some reason. Perhaps it does not want to be moved after the first run. Not sure. If you really want to move it do it before you run it I guess, at your own risk!

You should see an output like below:

firebase login screen

  1. In Firebase CLI use cd (change directory) commands to get to your flutter project folder, same as you would have done in Windows cmd.

  2. Still in Firebase CLI run the following command: dart pub global activate flutterfire_cli

  3. If the output says that C:\Users\[USER]\AppData\Local\Pub\Cache\bin is not on your path, you will have to add this to the path, then restart your pc. To add this to your path, search Windows Control Panel for "path"

Windows path

Don't forget to restart!

  1. If you had to restart to add a path, repeat steps from #2
  2. Finally run this command (also in Firebase CLI): flutterfire configure

2 Comments

Did no difference for me, I still get the same error :(
Just to note for others - I got it working eventually by installing firebase-tools via npm (install Node.JS on windows first), and then running the commands in Node.JS command console. The next problem with with the android version, but the fix was easy (use -a param on the configure command)
1

It's JDK Path Problem you need to add Java JDK do the following seps:

  1. Add JDK path to your user variables as example C:\Program Files\Java\jdk-16.0.2\bin.
  2. then restart your terminal and try again flutterfire configur command. it work with me.

Comments

0

just update your platform to latest version [windows or linux or mac] it worked for me , hope it helps someone

Comments

0

For me it is solved by running command in cmd itself not in internal terminal of Android Studio.

Running Command in Android Studio but not working

but

the same command in cmd itself is working and done

Comments

0

If you installed firebase-tools while your IDE was open, then you'd get that error if you run flutterfire configure afterwards. My guess is that environment variables got changed.

Solutions (any would work):

  1. Just restart the IDE. Worked for me.
  2. Open a new cmd window, navigate to your projects root directory and run the flutterfire configure command again

Comments

0

If you are trying in bash or other terminal then it will not know what is flutterfire . Try this command "flutterfire configure" in command prompt.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.