初始化Firebase Cloud Storage模拟器遇云资源位置配置错误
Firebase存储模拟器本地启动问题
我正在使用Firebase模拟器进行本地开发并测试Cloud Functions,其中一个场景涉及向Cloud Storage上传文件,操作流程及遇到的问题如下:
初始化Firebase模拟器
执行命令:
npx firebase init emulators
交互流程:
=== Emulators Setup ? Which Firebase emulators do you want to set up? Press Space to select emulators, then Enter to confirm your choices. Storage Emulator ? Which port do you want to use for the storage emulator? 9199 ? Would you like to enable the Emulator UI? Yes ? Which port do you want to use for the Emulator UI (leave empty to use any available port)? ? Would you like to download the emulators now? Yes
启动存储模拟器时出错
尝试启动仅包含存储服务的Firebase模拟器:
npx firebase emulators:start --only storage
收到错误提示:
Error: Cannot start the Storage emulator without rules file specified in firebase.json: run 'firebase init' and set up your Storage configuration
初始化存储服务时再次出错
由于启动Cloud Storage模拟器需要先创建storage.rules文件,我执行以下命令:
npx firebase init storage
收到错误提示:
=== Storage Setup Error: Cloud resource location is not set for this project but the operation you are attempting to perform in Cloud Storage requires it. 请查看相关官方文档了解详情
问题补充
我已在Firebase控制台启用存储服务,并选择了与其他Firebase服务一致的资源位置,但数小时后仍收到相同错误,本地Firebase环境未识别到存储服务已激活。
环境信息
• macOS Sequoia 15.0 • VS Code 1.95.1 • Node.js v18(也尝试过v20和v22) • Firebase CLI 13.23.1
内容的提问来源于stack exchange,提问作者Fabio Moggi
相关产品推荐
相关产品推荐

