如何解决在macOS中出现的zsh: command not found: flutterfire错误?

21
我按照文档中的指引,在我的Flutter应用程序中添加了Firebase。我收到了1个警告和以下消息:
    Warning: Pub installs executables into $HOME/.pub-cache/bin, which is not on your path.
    You can fix that by adding this to your shell's config file (.bashrc, .bash_profile, etc.):
Warning: Pub installs executables into $HOME/.pub-cache/bin, which is not on your path.
You can fix that by adding this to your shell's config file (.bashrc, .bash_profile, etc.):

  export PATH="$PATH":"$HOME/.pub-cache/bin"

Activated flutterfire_cli 0.1.1+2.

在此之后,我使用了
flutterfire configure

我遇到了这个错误(其实不是错误)zsh: command not found: flutterfire。如何解决?这是环境错误吗?

5个回答

83

在Mac上设置 zsh 路径:

  1. 运行 vim〜/ .zshrc
  2. i
  3. 粘贴 export PATH =“$ PATH”:“$ HOME / .pub-cache / bin”
  4. esc
  5. 键入: wq!并按 enter
  6. 重新启动终端

如果成功,则 which flutterfire 将起作用。


我试过使用梅森时它起作用了。 - Taldorr
适用于Mac M1 Pro。 - sweetnandha cse
在 Mac Air M1 上工作,非常棒。 - Breno AllenCS
在Mac M2 Pro上工作过 - yalda mohasseli
1
谢谢,兄弟!在Macbook M2 Pro上运行正常。 - undefined

35

以下是对我有效的方法:dart pub global run flutterfire_cli:flutterfire configure参考链接


是的,这对我有用,但是使用项目标志位: dart pub global run flutterfire_cli:flutterfire configure --project=YOUR_FIREBASE_PROJECT_ID - Faisal Shahzad
已经为我工作了几次,非常感谢你。 - undefined

12

[我正在使用 Mac] 这对我很有帮助,只需记住当您按照官方网站上的以下步骤时:

 npm install -g firebase-tools
 firebase login
 dart pub global activate flutterfire_cli
 flutterfire configure


如果flutterfire configure无法正常工作,则需要添加以下内容:
export PATH="$PATH":"$HOME/.pub-cache/bin" 

从您的Mac的主目录到您的.bash_profile。然后,重新启动系统,打开系统后,尝试在VS Code中再次运行flutterfire configure。它将起作用。然后:

flutter pub add firebase_core
flutter pub get

1

通过运行以下命令来设置FlutterFire路径: vim ~/.bash_profile 按下i键插入文本 粘贴路径 export PATH="$PATH":"$HOME/.pub-cache/bin" 按下esc键保存,然后输入:wq退出

您可以运行which flutterfire来检查路径是否正确


1

[1

  1. 运行 vim ~/.zshrc
  2. 按下 i 键
  3. 将 flutter/bin 路径粘贴如图所示
  4. 将 export PATH="$PATH":"$HOME/.pub-cache/bin" 粘贴进去
  5. 按下 esc 键
  6. 输入 :wq! 并按回车键
  7. 重新启动终端

这只是现有答案的副本。 - BugsOverBugs

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接