0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Firebase環境構築(共有用メモ)

Last updated at Posted at 2025-01-15

前提

エミュレータを動作させるためにはnode,jdkが必要です

エミュレータが原因不明のエラーで動作しない場合大体nodeのバージョンが対応していない(経験談)
起動コマンドは通ったのにhostingにアクセスしてみると画面真っ白、、、という経験がありましたので同様の症状の方は参考までに

公式ドキュメント

環境構築

CLIをインストール

ターミナルに以下のコマンドをたたく
グローバルにインストールしているのでどのディレクトリでも大丈夫

npm install -g firebase-tools

ログイン

firebaseプロジェクトを作成する(作成した)googleアカウントにログイン

firebase login

入力するとURLが出力されるので開いてログイン

プロジェクトの初期化

ログインが完了したら以下のコマンドでプロジェクトを初期化

firebase init

入力すると以下のような出力がされるので必要な項目まで↑↓キーで移動してスペースで確定
(Emulators: Set up local emulators for Firebase productsを選択するとローカルエミュレータが使えるよ)

? Which Firebase features do you want to set up for this directory? Press Space to select 
features, then Enter to confirm your choices. (Press <space> to select, <a> to toggle all, <i> to 
invert selection, and <enter> to proceed)
❯◯ Data Connect: Set up a Firebase Data Connect service
 ◯ Firestore: Configure security rules and indexes files for Firestore
 ◯ Genkit: Setup a new Genkit project with Firebase
 ◯ Functions: Configure a Cloud Functions directory and its files
 ◯ App Hosting: Configure an apphosting.yaml file for App Hosting
 ◯ Hosting: Configure files for Firebase Hosting and (optionally) set up GitHub Action deploys
 ◯ Storage: Configure a security rules file for Cloud Storage
(Move up and down to reveal more choices)

どのプロジェクトを使用するか聞かれるので選択
下二つはあまり使わないかも、、、?

ちなみに上二つは

  • 既存のプロジェクトを使用
  • 新たなプロジェクトを作成
? Please select an option: (Use arrow keys)
❯ Use an existing project 
  Create a new project 
  Add Firebase to an existing Google Cloud Platform project 
  Don't set up a default project 

使用するプロジェクトを選択すると選択した項目の初期化が始まるので基本的にはそのままEnterでOK

エミュレータ起動

初期化したディレクトリないで以下のコマンドを叩くと起動できます

firebase emulators:start

onlyオプションを使用して単体起動

例 : hostingのみ

firebase emulators:start --only hosting
0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?