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?

More than 1 year has passed since last update.

Cloud Functions for Firebaseをローカルで実行する方法

Posted at

FirebaseでCloud Functionsを使うときにはローカルでも実行できる環境が必須です。たとえデプロイするにしても1分くらいかかってしまいます。

そのため、この記事ではCloud Functions for Firebaseをローカルで動かす方法をまとめました。

手順

エミュレータを入れる

まず、ローカルにエミュレータを入れます。
functionsディレクトリにて、以下のコードを実行してください

firebase init emulators

functionsのみをインストールします。

※Firebaseプロジェクト作成時にfunctionsのemulatorを入れた人は不要みたいです

エミュレータを起動する

次に、エミュレータを実際に起動します。以下のコマンドを入力し実行してください。

firebase emulators:start --only functions

ローカルサーバーを起動する

最後に、以下のコマンドでサーバーを起動します。

firebase serve --only functions

以上です!
これでlocalhost:5000とかで動くはずです。

参考

詳しくは、以下の2つの公式ドキュメントを参照してください。

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?