未找到颤振命令 [英] Flutter command not found

查看:34
本文介绍了未找到颤振命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

显然,没有任何 Flutter 命令在 Android Studio 的终端中运行,我相信我正在尝试在我的项目的根目录中运行它.

Apparently, none of the Flutter commands are working in the terminal of Android Studio which I believe I am trying to run it at the root of my project.

输出:

bash: flutter: command not found

推荐答案

您需要正确设置 Flutter 路径.

You need to correctly set up your Flutter path.

来自 macOS 安装 - 更新您的路径:

  1. 确定放置 Flutter SDK 的目录.您将在第 3 步中用到它.

  1. Determine the directory where you placed the Flutter SDK. You will need this in Step 3.

打开(或创建)$HOME/.bash_profile.您可以使用终端文本编辑器进入终端并输入 nano ~/.bash_profile

Open (or create) $HOME/.bash_profile. You can do that by using terminal text editor by going in terminal and typing nano ~/.bash_profile

macOS v10.15 (Catalina) 默认使用 Z shell,所以编辑 $fileHOME/.zshrc.

macOS v10.15 (Catalina) uses the Z shell by default, so edit $file HOME/.zshrc.

如果您使用不同的 shell,文件路径和文件名在您的机器上会有所不同.

If you are using a different shell, the file path and filename will be different on your machine.

添加以下行并将[PATH_TO_FLUTTER_GIT_DIRECTORY]更改为您克隆Flutter的Git存储库的路径:

Add the following line and change [PATH_TO_FLUTTER_GIT_DIRECTORY] to be the path where you cloned Flutter’s Git repository is:

 export PATH=[PATH_TO_FLUTTER_GIT_DIRECTORY]/flutter/bin:$PATH

例如:

 export PATH=~/Documents/flutter/bin:$PATH

  • Ctrl + X,当它要求你保存文件时,选择

  • Press Ctrl + X and when it asks you to save the file, choose Yes

    运行 source $HOME/.bash_profile 刷新当前窗口或重启终端

    Run source $HOME/.bash_profile to refresh the current window or restart the terminal

    通过运行以下命令验证 flutter/bin 目录现在是否在您的 PATH 中:

    Verify that the flutter/bin directory is now in your PATH by running:

     echo $PATH
    

    请注意,[PATH_TO_FLUTTER_GIT_DIRECTORY] 是您安装 Flutter SDK 的位置,而不是您应用的位置

    Notice that [PATH_TO_FLUTTER_GIT_DIRECTORY] is where you installed Flutter SDK, not the location of your app

    代替nano,您可以使用任何文本编辑器来编辑文件~/.bash_profile.

    Instead of nano, you can use any text editor to edit file ~/.bash_profile.

    对于 zsh:

    1. 打开终端
    2. 运行:nano ~/.zshrc
    3. 添加:export PATH=[PATH_TO_FLUTTER_GIT_DIRECTORY]/flutter/bin:$PATH
    4. 运行:source ~/.zshrc
    5. 重启终端
    6. 运行:flutter doctor -v

    例如:如果你机器上的flutter已经安装在[your_username]/Developer/flutter下

    For example : if flutter in your machine has been installed under [your_username]/Developer/flutter

    export PATH=Developer/flutter/bin:$PATH
    

    这篇关于未找到颤振命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆