术语 'flutterfire' 未被识别为 cmdlet、函数、脚本文件或可运行程序的名称
The term 'flutterfire' is not recognized as the name of a cmdlet, function, script file, or operable program
我正在尝试在我的根项目中安装 flutterfire_cli,所以我输入了这个命令:
FirebaseFirestore firestore = FirebaseFirestore.instance;
所以之后,这是我的控制台的输出:
PS C:\Users\PC\Desktop\eventually> dart pub global activate flutterfire_cli
Package flutterfire_cli is currently active at version 0.1.1+2.
Resolving dependencies...
The package flutterfire_cli is already activated at newest available version.
To recompile executables, first run `global deactivate flutterfire_cli`.
Installed executable flutterfire.
Warning: Pub installs executables into C:\Users\PC\AppData\Local\Pub\Cache\bin, which is not on your path.
You can fix that by adding that directory to your system's "Path" environment variable.
A web search for "configure windows path" will show you how.
Activated flutterfire_cli 0.1.1+2.
为了修复警告,我在系统变量环境中的路径中添加了 C:\Users\PC\AppData\Local\Pub\Cache\bin。 (但它不起作用,我仍然收到警告)
接下来,我正在尝试生成 firebase_options.dart 文件,正如 documentation 所说,使用此命令:
flutterfire configure
但我在控制台中收到错误消息:
PS C:\Users\PC\Desktop\eventually> flutterfire configure
flutterfire : The term 'flutterfire' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ flutterfire configure
+ ~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (flutterfire:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
谁能告诉我我遗漏了什么,为什么即使我的机器上已经安装了 Firebase CLI 也会出现此错误?
仔细阅读此文档:https://firebase.flutter.dev/docs/cli/
第 1 步:安装 Firebase CLI
第 2 步:使用此命令安装 FlutterFire CLI dart pub global activate flutterfire_cli
执行此操作时,您必须注意以下警告
Warning: Pub installs executables into C:\Users\PC\AppData\Local\Pub\Cache\bin, which is not on your path. You can fix that by adding that directory to your system's "Path" environment variable. A web search for "configure windows path" will show you how.
这意味着您需要将 C:\Users\*username*\AppData\Local\Pub\Cache\bin
添加到系统的环境路径中。
第 3 步:现在 flutterfire configure
应该可以工作了。
如果还是不行就玩Firebase commands
即使在我的路径中添加 C:\Users\PC\AppData\Local\Pub\Cache\bin flutterfire 也无法从命令行运行,原因是它实际上安装了一个 flutterfire.bat 文件。
所以我现在在命令行中使用 flutterfire.bat 并且可以正常工作。
至于我,我已经正确地完成了所有操作,如果我在 Windows 命令提示符下 运行 命令可以正常工作,但是如果我在 VS 代码终端中键入命令,它就无法正常工作.
所以我干脆把终端杀了再打开,然后就可以了。
或者,您可以尝试重启机器。
使用命令提示符..而不是 vsc 终端
这是在 Mac 上向您的路径添加内容的非常简单的说明,它解决了我使用 Flutter 和 Flutterfire 的问题。
如果您按照正确的答案进行操作但仍然无法正常工作,您需要重新启动计算机
对于 Linux/Ubuntu,您应该执行以下操作:
- 使用命令“sudo nano ~/.bashrc”打开 .bashrc 文件
- 将 export PATH="$PATH":"$HOME/.pub-cache/bin" 添加到文件末尾。
- 最后你可以使用“source ~/.bashrc”获取文件
- 现在应该可以识别文件了。
我正在尝试在我的根项目中安装 flutterfire_cli,所以我输入了这个命令:
FirebaseFirestore firestore = FirebaseFirestore.instance;
所以之后,这是我的控制台的输出:
PS C:\Users\PC\Desktop\eventually> dart pub global activate flutterfire_cli
Package flutterfire_cli is currently active at version 0.1.1+2.
Resolving dependencies...
The package flutterfire_cli is already activated at newest available version.
To recompile executables, first run `global deactivate flutterfire_cli`.
Installed executable flutterfire.
Warning: Pub installs executables into C:\Users\PC\AppData\Local\Pub\Cache\bin, which is not on your path.
You can fix that by adding that directory to your system's "Path" environment variable.
A web search for "configure windows path" will show you how.
Activated flutterfire_cli 0.1.1+2.
为了修复警告,我在系统变量环境中的路径中添加了 C:\Users\PC\AppData\Local\Pub\Cache\bin。 (但它不起作用,我仍然收到警告)
接下来,我正在尝试生成 firebase_options.dart 文件,正如 documentation 所说,使用此命令:
flutterfire configure
但我在控制台中收到错误消息:
PS C:\Users\PC\Desktop\eventually> flutterfire configure
flutterfire : The term 'flutterfire' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ flutterfire configure
+ ~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (flutterfire:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
谁能告诉我我遗漏了什么,为什么即使我的机器上已经安装了 Firebase CLI 也会出现此错误?
仔细阅读此文档:https://firebase.flutter.dev/docs/cli/
第 1 步:安装 Firebase CLI
第 2 步:使用此命令安装 FlutterFire CLI dart pub global activate flutterfire_cli
执行此操作时,您必须注意以下警告
Warning: Pub installs executables into C:\Users\PC\AppData\Local\Pub\Cache\bin, which is not on your path. You can fix that by adding that directory to your system's "Path" environment variable. A web search for "configure windows path" will show you how.
这意味着您需要将 C:\Users\*username*\AppData\Local\Pub\Cache\bin
添加到系统的环境路径中。
第 3 步:现在 flutterfire configure
应该可以工作了。
如果还是不行就玩Firebase commands
即使在我的路径中添加 C:\Users\PC\AppData\Local\Pub\Cache\bin flutterfire 也无法从命令行运行,原因是它实际上安装了一个 flutterfire.bat 文件。
所以我现在在命令行中使用 flutterfire.bat 并且可以正常工作。
至于我,我已经正确地完成了所有操作,如果我在 Windows 命令提示符下 运行 命令可以正常工作,但是如果我在 VS 代码终端中键入命令,它就无法正常工作.
所以我干脆把终端杀了再打开,然后就可以了。
或者,您可以尝试重启机器。
使用命令提示符..而不是 vsc 终端
如果您按照正确的答案进行操作但仍然无法正常工作,您需要重新启动计算机
对于 Linux/Ubuntu,您应该执行以下操作:
- 使用命令“sudo nano ~/.bashrc”打开 .bashrc 文件
- 将 export PATH="$PATH":"$HOME/.pub-cache/bin" 添加到文件末尾。
- 最后你可以使用“source ~/.bashrc”获取文件
- 现在应该可以识别文件了。