初始化Firebase CLI部署React应用时遭遇项目列表加载失败问题
在初始化Firebase CLI部署React应用时,选择「使用现有项目」后触发如下错误:
? Are you ready to proceed? Yes
? Which Firebase features do you want to set up for this directory? Press Space to select features, then Enter to confirm your choices. Hosting: Configure files for Firebase Hosting and (optionally) set up GitHub Action deploys=== Project Setup
First, let's associate this project directory with a Firebase project.
You can create multiple project aliases by running firebase use --add,
but for now we'll just set up a default project.? Please select an option: Use an existing project
Error: Failed to list Firebase projects. See firebase-debug.log for more info.
PS C:\Users\xxxxxlinked-in>
已尝试的操作:
- 执行
firebase login可成功登录 - 尝试
firebase login --reauth重新授权 - 重新全局安装工具
npm install -g firebase-tools - 执行
firebase projects:list同样报错
检查账号项目权限
确认当前登录的Google账号拥有目标Firebase项目的有效权限(至少为「编辑者」),可以在Firebase控制台的「项目设置-用户与权限」页面核对账号权限状态。手动绑定项目ID跳过列表流程
直接用命令指定项目ID完成绑定,无需走交互式列表选择:firebase use --add <你的Firebase项目ID>项目ID可在Firebase控制台的项目设置页面获取,绑定完成后再执行
firebase init hosting即可直接使用该项目。排查网络环境限制
Firebase CLI需访问Google API,若处于企业防火墙或代理环境下,可能被拦截。尝试切换到无限制的个人网络(如手机热点),或为CLI配置代理:
Windows环境:set HTTP_PROXY=http://代理地址:端口 set HTTPS_PROXY=http://代理地址:端口Mac/Linux环境:
export HTTP_PROXY=http://代理地址:端口 export HTTPS_PROXY=http://代理地址:端口分析debug日志定位根因
打开错误提示中的firebase-debug.log,搜索「error」关键词,日志会记录请求失败的具体原因(如权限不足、API超时、认证异常等),根据提示针对性解决。降级到稳定版Firebase CLI
部分新版本CLI可能存在兼容性问题,尝试降级到已知稳定版本:npm install -g firebase-tools@12.9.1
内容的提问来源于stack exchange,提问作者Chickenwhisperer

