运行flutter doctor报错:Windows Version检查崩溃(找不到powershell)
解决Flutter Doctor提示“Failed to find 'powershell' in the search path”问题
问题重现
运行flutter doctor时出现如下错误:
Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel stable, 3.22.2, on Microsoft Windows [Version 10.0.22631.3880], locale en-US) [☠] Windows Version (the doctor check crashed) X Due to an error, the doctor check did not complete. If the error message below is not helpful, please let us know about this issue at https://github.com/flutter/flutter/issues. X ProcessException: Failed to find "powershell" in the search path. Command: powershell
解决方案
定位PowerShell安装路径
Windows系统中PowerShell默认路径通常是以下两个之一:- 传统Windows PowerShell:
C:\Windows\System32\WindowsPowerShell\v1.0 - PowerShell 7(若安装):
C:\Program Files\PowerShell\7
可以直接在文件资源管理器中导航到对应路径,确认powershell.exe存在。
- 传统Windows PowerShell:
添加路径到系统环境变量
- 右键点击「此电脑」→ 选择「属性」→ 点击「高级系统设置」
- 在弹出的窗口中切换到「高级」标签页,点击「环境变量」
- 在「系统变量」区域找到
Path变量,点击「编辑」 - 点击「新建」,粘贴刚才确认的PowerShell路径,然后点击「确定」保存所有设置
验证修复效果
- 关闭所有已打开的终端窗口(包括CMD、PowerShell、VS Code终端等)
- 重新打开一个终端,运行
flutter doctor,检查Windows Version项是否恢复正常
如果操作后问题仍存在,建议重启电脑确保环境变量完全生效,或确认PowerShell的实际安装路径是否与上述一致。
内容的提问来源于stack exchange,提问作者Alishba Haider
相关产品推荐
相关产品推荐

