この記事について
「firebase emulators:start」を実行したら、下記エラーが出たので、その対処法を載せます。
$ firebase emulators:start
i emulators: Starting emulators: functions, firestore
! functions: The following emulators are not running, calls to these services from the Functions emulator will affect production: auth, database, hosting, pubsub
+ functions: Using node@14 from host.
i firestore: Firestore Emulator logging to firestore-debug.log
! firestore: Fatal error occurred:
Firestore Emulator has exited because java is not installed, you can install it from https://openjdk.java.net/install/,
stopping all running emulators
i functions: Stopping Functions Emulator
i firestore: Stopping Firestore Emulator
! firestore: Error stopping Firestore Emulator
i hub: Stopping emulator hub
エラー原因
javaがインストールされてないからです。
対処法
Javaをインストールします。
まず、コマンドラインからは https://openjdk.java.net/install/ からインストールできると書いてありますが、サイトに行っても、正直何をすればいいのかわからなかった。。。
(頑張って5,6個ほど、それっぽいのをダウンロードしたつもりでしたが、どれもJavaのインストールには繋がらなかった。)
なので、Javaの公式サイトからインストールしました。
https://www.java.com/ja/download/manual.jsp
から「Windows オンライン」をクリック。(ダウンロードが始まる。)
ダウンロードされた「jre-8u271-windows-i586-iftw.exe」を実行。
そのまま進めると、何事もなく、正常にインストールされました。
これでJavaがインストールされたはずです。
再実行
__「VSCode」を再起動__して、もう一度「firebase emulators:start」を実行。
「Windows セキュリティの重要な警告」が表示されるので、
「アクセスを許可する」をクリックします。
すると、こんな感じで、正常に立ち上がりました。
$ firebase emulators:start
i emulators: Starting emulators: functions, firestore
! functions: The following emulators are not running, calls to these services from the Functions emulator will affect production: auth, database, hosting, pubsub
+ functions: Using node@14 from host.
i firestore: Firestore Emulator logging to firestore-debug.log
i ui: downloading ui-v1.4.1.zip...
Progress: =============================================================================================================================================================> (100% of 4MB)
i ui: Emulator UI logging to ui-debug.log
i functions: Watching "directory\firebase-cloud-function-for-practice\functions" for Cloud Functions...
+ functions[addMessage]: http function initialized (http://localhost:5001/firestore-practice-38725/us-central1/addMessage).
+ functions[makeUppercase]: firestore function initialized.
┌─────────────────────────────────────────────────────────────┐
│ ✔ All emulators ready! It is now safe to connect your app. │
│ i View Emulator UI at http://localhost:4000 │
└─────────────────────────────────────────────────────────────┘
┌───────────┬────────────────┬─────────────────────────────────┐
│ Emulator │ Host:Port │ View in Emulator UI │
├───────────┼────────────────┼─────────────────────────────────┤
│ Functions │ localhost:5001 │ http://localhost:4000/functions │
├───────────┼────────────────┼─────────────────────────────────┤
│ Firestore │ localhost:8080 │ http://localhost:4000/firestore │
└───────────┴────────────────┴─────────────────────────────────┘
Emulator Hub running at localhost:4400
Other reserved ports: 4500
Issues? Report them at https://github.com/firebase/firebase-tools/issues and attach the *-debug.log files.
やったー(^o^)/