You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows下CMD输入dart/flutterfire后窗口秒关问题求助

问题描述

误删系统PATH环境变量后,在Windows CMD中输入dart、flutterfire等命令时,窗口会直接关闭且无任何报错。已尝试重装Flutter SDK,但问题未解决。

Flutter Doctor检测结果

[√] Flutter (Channel master, 3.8.0-14.0.pre.8, in Microsoft Windows [version 10.0.19044.2604], localization ru-RU)
[√] Windows version (installed version of Windows - version 10 or higher)
[√] Android toolchain - development for Android devices (Android SDK version 32.1.0-rc1)
[√] Chrome - development for the Internet
[!] Visual Studio - development for Windows (Visual Studio Community 2022 17.4.3)
X Visual Studio lacks the necessary components. Please re-run the Visual Studio installer for the "Desktop Development using C++" workload and enable these components:
MSVC v142 - VS 2019 C++ x64/x86 Build Tools
- If multiple versions of the build tool are available, install the latest one
C++ CMake Tools for Windows
Windows 10 SDK
[√] Android Studio (version 2021.2)
[√] Android Studio (version 4.1)
[√] VS Code (version 1.75.1)
[√] Connected device (available 3)
[√] Network resources

环境变量情况

  • 已提供系统PATH和用户PATH的截图,用户PATH中包含Flutter相关路径。

解决方案
  1. 恢复系统核心PATH条目
    误删系统PATH会导致Windows核心工具无法正常运行,这是CMD窗口闪退的主要原因。立即添加以下基础路径到系统PATH:

    • C:\Windows\system32
    • C:\Windows
    • C:\Windows\System32\Wbem
    • C:\Windows\System32\WindowsPowerShell\v1.0\
    • C:\Windows\System32\OpenSSH\
  2. 确认Flutter/Dart相关路径配置
    确保以下路径存在于用户或系统PATH中:

    • Flutter SDK的bin目录(例如C:\flutter\bin,根据实际安装路径调整)
    • Dart可执行文件路径(通常集成在Flutter的bin目录下,若单独安装则为C:\dart-sdk\bin)
    • Flutterfire CLI路径(一般为%USERPROFILE%\AppData\Local\Pub\Cache\bin)
  3. 补全Visual Studio缺失组件
    按照flutter doctor提示操作:打开Visual Studio安装器,勾选「使用C++的桌面开发」工作负载,确保勾选以下组件并完成安装:

    • MSVC v142 - VS 2019 C++ x64/x86生成工具(选择最新版本)
    • Windows 10 SDK
    • C++ CMake工具
  4. 验证修复效果
    完成上述步骤后必须重启CMD窗口(环境变量变更需重启终端生效),依次执行以下命令:

    • echo %PATH%:检查PATH是否包含所有必要路径
    • dart --version:验证Dart命令是否正常响应
    • flutter doctor:重新检测Flutter环境完整性
  5. 捕获具体报错信息
    若仍出现窗口闪退,打开CMD后先执行cmd /k dart --version,强制窗口保持打开,即可查看具体报错内容,再根据报错排查问题。


内容的提问来源于stack exchange,提问作者l_rTM

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.03 15:35:27