出现错误 zsh:找不到命令:flutterfire

问题描述 投票:0回答:1

我正在 flutter 中开发应用程序,并对我的 flutter 应用程序进行了 firebase 配置。使用 IDE - VSCode,为 flutter 项目配置 Firebase。

我一直收到错误:

zsh:找不到命令:flutterfire,给出错误未定义名称“DefaultFirebaseOptions”。
尝试将名称更正为已定义的名称,或定义 name.dart
未定义的标识符

这是我的代码-

import 'firebase_options.dart';


Future<void> main() async {`enter code here`
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp(
    options: DefaultFirebaseOptions.currentPlatform,
  );
  
  runApp(const MyApp());
}
        

我总是遇到错误

    logcat ==

    getting error -  zsh: command not found: flutterfire
    
         flutterfire configure
        zsh: command not found: flutterfire
flutter firebase configure
1个回答
0
投票

错误表示您的环境中未正确配置

flutterfire
CLI。 根据文档,您必须按以下方式安装它:

dart pub global activate flutterfire_cli

此命令会将

flutterfire
命令添加到您的路径中,并且可以在您的构建中访问它。 之后您还应该重新启动 IDE,以防出现
PATH
的问题。

完成所有这些操作后,应该可以从您的终端访问

flutterfire
,如下检查:

flutterfire --help
A CLI tool for FlutterFire projects.

Usage: flutterfire <command> [arguments]

Global options:
-h, --help       Print this usage information.
    --verbose    Enable verbose logging.
-v, --version    Print the current CLI version.

Available commands:
  configure     Configure Firebase for your Flutter app. This command will fetch Firebase configuration for you and generate a Dart file with prefilled FirebaseOptions you can use.
  reconfigure   Updates the configurations for all build variants included in the "firebase.json" added by running `flutterfire configure`.
  update        Update the version of firebase plugins in your pubspec to the latest version and clean your workspace to ensure that everything works properly.

Run "flutterfire help <command>" for more information about a command.

此外,添加

.pub-cache
给你
PATH
也很重要。通常是在
$HOME/.pub-cache/bin

© www.soinside.com 2019 - 2024. All rights reserved.