FlutterFire configure CLI requires the official Firebase CLI

Viewed 1087

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
+ firebase-tools@11.0.1
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 har-validator@5.1.3: this library is no longer supported
npm WARN deprecated debug@4.1.1: 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 uuid@3.4.0: 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 request@2.88.2: 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.

4 Answers

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

The problem resulted from conflicting installations.

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.

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.

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

Related