0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Firebase】Cloud Storageのせいでエミュレーターの起動に失敗した

Posted at

はじめに

firebase emulators:startを実行して、エミュレーターを初めて起動した時にCloud Storageに関するエラーに遭遇した。

Error: Cannot start the Storage emulator without rules file specified in firebase.json: run 'firebase init' and set up your Storage configuration

Firebaseコンソール上でのCloud Storageの未設定によるエラー

とりあえず、firebase initを実行してCloud Storageの設定を追加しようとした。

? Which Firebase features do you want to set up for this directory? Press Space to select features, then Enter to confirm your choices. (Pres
s <space> to select, <a> to toggle all, <i> to invert selection, and <enter> to proceed)
 ◯ Functions: Configure a Cloud Functions directory and its files
 ◯ Hosting: Configure files for Firebase Hosting and (optionally) set up GitHub Action deploys
 ◯ Hosting: Set up GitHub Action deploys
❯◉ Storage: Configure a security rules file for Cloud Storage
 ◯ Emulators: Set up local emulators for Firebase products
 ◯ Remote Config: Configure a template file for Remote Config
 ◯ Realtime Database: Configure a security rules file for Realtime Database and (optionally) provision default instance
(Move up and down to reveal more choices)

またエラーが出た。

Cloud resource location is not set for this project but the operation you are attempting to perform in Cloud Storage requires it. Please see this documentation for more details: https://firebase.google.com/docs/projects/locations

FirebaseコンソールでCloud Storageを設定

Firebaseコンソールで、Storageのページを開いて「はじめる」をクリックする。

5.png

とりあえず、テストモードを選択して次へ進む。

6.png

ロケーションを選択して完了をクリックする。

7.png

次のような画面が表示された完了。

8.png

storage.rulesファイルを作成

FirebaseコンソールでCloud Storageの設定後、firebase initを再度実行した。

そのままエンターキーを押下して、ルートディレクトリにstorage.rulesを作成した。

=== Storage Setup

Firebase Storage Security Rules allow you to define how and when to allow
uploads and downloads. You can keep these rules in your project directory
and publish them with firebase deploy.

? What file should be used for Storage Rules? storage.rules
✔  Wrote storage.rules

i  Writing configuration info to firebase.json...
i  Writing project information to .firebaserc...
✔  Firebase initialization complete!

これで問題なくFirebaseエミュレーターを起動できる。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?