Flutterfire配置CLI需要官方的Firebase CLI
我有一个问题可以为我的项目配置Flutter Fire。我使用npm install -g firebase -tool安装了 - force,然后尝试了> Dart Pub全局激活FlutterFire_Cli,但我仍然对CLI有问题。我可以登录并查看该版本,但是
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.
在阅读Stackoverflow上的所有主题和Internet上我无法解决问题后,我无法运行FlutterFire配置,有什么想法吗? 运行NPM install -G firebase -tools我得到了:
> 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
现在出现此错误:
⠋ 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>
新闻
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
删除先前安装的
firebase.exe
,然后依靠firebase
仅通过npm install -G firebase -tools
安装。问题是由于安装冲突而引起的。
Remove the previously installed
firebase.exe
and rely onfirebase
installed vianpm install -g firebase-tools
only.The problem resulted from conflicting installations.
如果您获得
formateXception:意外字符(在字符1)
错误,请查看是否在扑朔迷离主文件夹中有 firebase.exe 文件。这是我的问题。删除文件后,FlutterFire配置
毫无问题。澄清:
我已经将firebase-cli二进制文件(firebase-tools-instant-win.exe)添加到我的Flutter Project的主要文件夹中,并将其重命名为Firebase.exe,因为Previuos错误修复了尝试。如果您没有这样做,那么您的颤动主文件夹中不应有firebase二进制文件。
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.
在使用大量错误
确保您没有下载Windows EXE,因为在运行Firebase/FlutterFire时可能会发生冲突。对我来说,诀窍是确保我使用NVM安装NPM,将NPM Global的默认目录安装设置为默认设置以外的其他功能。我相信这是一个许可问题。
Resolved for me by doing the following after struggling with plenty of errors
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.
解决方案2023用于Windows 11
firebase-tool-instant-win.exe
)“下载”文件夹您应该看到下面的输出:
仍然在firebase CLI中运行以下命令:
DART PUB全局激活FlutterFire_Cli
如果输出说
c:\ users \ [user] \ appdata \ local \ local \ pub \ cache \ bin
不在您的路径上,您必须将其添加到路径中,然后重新启动PC。要将其添加到您的路径中,请搜索Windows Control面板的“路径”不要忘记重新启动!
FlutterFire配置
Solution 2023 for Windows 11
firebase-tool-instant-win.exe
) to "Downloads" folderYou should see an output like below:
In Firebase CLI use
cd
(change directory) commands to get to your flutter project folder, same as you would have done in Windows cmd.Still in Firebase CLI run the following command:
dart pub global activate flutterfire_cli
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"Don't forget to restart!
flutterfire configure
这是JDK路径问题,您需要添加Java JDK执行以下SEP:
c:\ program Files \ Java \ Java \ JDK-16.0.2 \ bin
。FlutterFire Configur
命令。它和我一起工作。
It's JDK Path Problem you need to add Java JDK do the following seps:
C:\Program Files\Java\jdk-16.0.2\bin
.flutterfire configur
command.it work with me.
只需将您的平台更新到最新版本[Windows或Linux或Mac],它对我有用,希望它能帮助某人
just update your platform to latest version [windows or linux or mac] it worked for me , hope it helps someone
对我来说,它可以通过在CMD本身中不在Android Studio的内部终端中运行命令来解决。
但是
For me it is solved by running command in cmd itself not in internal terminal of Android Studio.
but
如果您在IDE打开时安装了Firebase-Tools,则在运行
FlutterFire Configure
之后,您将获得该错误。我的猜测是环境变量发生了变化。解决方案(任何可以使用):
FlutterFire Configure
命令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):
flutterfire configure
command again如果您尝试使用bash或其他终端,那么它将不知道什么是Flutterfire。在命令提示符中尝试此命令“ FlutterFire配置”。
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.