Flutterfire配置CLI需要官方的Firebase CLI

发布于 2025-02-03 19:10:39 字数 3984 浏览 2 评论 0 原文

我有一个问题可以为我的项目配置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.

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

智商已欠费 2025-02-10 19:10:39

删除先前安装的 firebase.exe ,然后依靠 firebase 仅通过 npm install -G firebase -tools 安装。

问题是由于安装冲突而引起的。

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

The problem resulted from conflicting installations.

沦落红尘 2025-02-10 19:10:39

如果您获得 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.

影子的影子 2025-02-10 19:10:39

在使用大量错误

  1. 使用NVM来安装最新节点
  2. 后,通过执行以下操作来解决以下方面的解决方案,使用prefix命令更改Windows PC上的软件包的默认目录。对我来说,我在这里创建了目录%appdata%.npm-global,然后转到此目录,然后使用前缀命令设置NPM全局软件包的默认值
  3. 确保此路径在您的Windows路径
  4. 安装firebase install firebase工具中npm npt install-g firebase install -g firebase-tol
  5. . CLI DART PUB全局激活FlutterFire_Cli
  6. CD到我的Flutter应用程序目录,
  7. 从命令提示符firebase登录
  8. 类型FlutterFire配置

确保您没有下载Windows EXE,因为在运行Firebase/FlutterFire时可能会发生冲突。对我来说,诀窍是确保我使用NVM安装NPM,将NPM Global的默认目录安装设置为默认设置以外的其他功能。我相信这是一个许可问题。

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.

迷迭香的记忆 2025-02-10 19:10:39

解决方案2023用于Windows 11

  1. 下载独立二进制 firebase-tool-instant-win.exe )“下载”文件夹
  2. 从下载中运行可执行文件。不要移动它或重命名它,因此由于某种原因而感到不高兴。也许它不想在第一次运行后移动。没有把握。如果您真的想移动它,请在运行它之前,就会自负!

您应该看到下面的输出:

  1. ​Windows CMD。

  2. 仍然在firebase CLI中运行以下命令:
    DART PUB全局激活FlutterFire_Cli

  3. 如果输出说 c:\ users \ [user] \ appdata \ local \ local \ pub \ cache \ bin 不在您的路径上,您必须将其添加到路径中,然后重新启动PC。要将其添加到您的路径中,请搜索Windows Control面板的“路径”

“

不要忘记重新启动!

  1. 如果您必须重新启动添加路径,请重复#2的步骤
  2. ,最终运行此命令(也在Firebase CLI中):
    FlutterFire配置

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
柏林苍穹下 2025-02-10 19:10:39

这是JDK路径问题,您需要添加Java JDK执行以下SEP:

  1. 将JDK路径添加到用户变量为示例 c:\ program Files \ Java \ Java \ JDK-16.0.2 \ bin
  2. 然后重新启动终端,然后重试 FlutterFire Configur 命令。
    它和我一起工作。

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.
箹锭⒈辈孓 2025-02-10 19:10:39

只需将您的平台更新到最新版本[Windows或Linux或Mac],它对我有用,希望它能帮助某人

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

怂人 2025-02-10 19:10:39

对我来说,它可以通过在CMD本身中不在Android Studio的内部终端中运行命令来解决。

但是

”

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

乖不如嘢 2025-02-10 19:10:39

如果您在IDE打开时安装了Firebase-Tools,则在运行 FlutterFire Configure 之后,您将获得该错误。我的猜测是环境变量发生了变化。

解决方案(任何可以使用):

  1. 只需重新启动IDE即可。为我工作。
  2. 打开一个新的CMD窗口,导航到您的项目root Directory并再次运行 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):

  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
红ご颜醉 2025-02-10 19:10:39

如果您尝试使用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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文