質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Firebase

Firebaseは、Googleが提供するBasSサービスの一つ。リアルタイム通知可能、並びにアクセス制御ができるオブジェクトデータベース機能を備えます。さらに認証機能、アプリケーションのログ解析機能などの利用も可能です。

JavaScript

JavaScriptは、プログラミング言語のひとつです。ネットスケープコミュニケーションズで開発されました。 開発当初はLiveScriptと呼ばれていましたが、業務提携していたサン・マイクロシステムズが開発したJavaが脚光を浴びていたことから、JavaScriptと改名されました。 動きのあるWebページを作ることを目的に開発されたもので、主要なWebブラウザのほとんどに搭載されています。

Q&A

0回答

1639閲覧

Cloud Functions(Firebase)への関数デプロイ。エラーが解決できません

ryota002

総合スコア18

Firebase

Firebaseは、Googleが提供するBasSサービスの一つ。リアルタイム通知可能、並びにアクセス制御ができるオブジェクトデータベース機能を備えます。さらに認証機能、アプリケーションのログ解析機能などの利用も可能です。

JavaScript

JavaScriptは、プログラミング言語のひとつです。ネットスケープコミュニケーションズで開発されました。 開発当初はLiveScriptと呼ばれていましたが、業務提携していたサン・マイクロシステムズが開発したJavaが脚光を浴びていたことから、JavaScriptと改名されました。 動きのあるWebページを作ることを目的に開発されたもので、主要なWebブラウザのほとんどに搭載されています。

0グッド

0クリップ

投稿2021/02/12 09:37

編集2021/02/13 07:09

前提・実現したいこと

FirebaseのCloud Functionsに関数をデプロイしたいです。
ターミナルで「firebase deploy」を行った結果以下のエラーメッセージが出てしましました。

発生している問題・エラーメッセージ

⚠ functions[helloWorld(us-central1)]: Deployment error. Function failed on loading user code. This is likely due to a bug in the user code. Error message: Error: please examine your function logs to see the error cause: https://cloud.google.com/functions/docs/monitoring/logging#viewing_logs. Additional troubleshooting documentation can be found at https://cloud.google.com/functions/docs/troubleshooting#logging. Please visit https://cloud.google.com/functions/docs/troubleshooting for in-depth troubleshooting documentation. ⚠ functions[addMessage(us-central1)]: Deployment error. Function failed on loading user code. This is likely due to a bug in the user code. Error message: Error: please examine your function logs to see the error cause: https://cloud.google.com/functions/docs/monitoring/logging#viewing_logs. Additional troubleshooting documentation can be found at https://cloud.google.com/functions/docs/troubleshooting#logging. Please visit https://cloud.google.com/functions/docs/troubleshooting for in-depth troubleshooting documentation. Functions deploy had errors with the following functions: addMessage helloWorld To try redeploying those functions, run: firebase deploy --only "functions:addMessage,functions:helloWorld" To continue deploying other features (such as database), run: firebase deploy --except functions Error: Functions did not deploy properly.

該当のソースコード

js

1const functions = require('firebase-functions'); 2 3const admin = require('firebase-admin'); 4admin.initializeApp(); 5 6 7exports.helloWorld = functions.https.onRequest((request, response) => { 8 functions.logger.info("Hello logs!", {structuredData: true}); 9 response.send("Hello from Firebase!"); 10}); 11 12exports.addMessage = functions.https.onRequest(async (req, res) => { 13 const original = req.query.text; 14 const writeResult = await admin.firestore().collection('messages').add({original: original}); 15 res.json({result: `Message with ID: ${writeResult.id} added.`}); 16});

試したこと

エラーメッセージで検索しましたが、有効な情報にたどり着けませんでした。

補足情報(FW/ツールのバージョンなど)

Firebase
cloud functions
JavaScript

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

ryota002

2021/02/12 10:20

コメントありがとうございます。 ローカルで確認しようとすると、以下のようなメッセージが出て、確認ができない状況で、、、 エラーメッセージを読んだ感じFirestoreに問題があるのかなと、、 $ firebase emulators:start i emulators: Starting emulators: functions, firestore, hosting ⚠ functions: The following emulators are not running, calls to these services from the Functions emulator will affect production: auth, database, pubsub ⚠ Your requested "node" version "12" doesn't match your global version "14" i firestore: Firestore Emulator logging to firestore-debug.log ⚠ firestore: Fatal error occurred: Firestore Emulator has exited with code: 1, stopping all running emulators i functions: Stopping Functions Emulator i firestore: Stopping Firestore Emulator ⚠ firestore: Error stopping Firestore Emulator i hub: Stopping emulator hub
ryota002

2021/02/12 12:37

nodeのバージョンをv12.16.1に落としてみたのですが、うまくエミュレーターが起動しませんでした、、、 npmも調べて試してみます。 バージョンを落としても、以下のように同じようなエラーが出てしまいました、、 $ firebase emulators:start i emulators: Starting emulators: functions, firestore, hosting ⚠ functions: The following emulators are not running, calls to these services from the Functions emulator will affect production: auth, database, pubsub ✔ functions: Using node@12 from host. i firestore: Firestore Emulator logging to firestore-debug.log ⚠ firestore: Fatal error occurred: Firestore Emulator has exited with code: 1, stopping all running emulators i functions: Stopping Functions Emulator i firestore: Stopping Firestore Emulator ⚠ firestore: Error stopping Firestore Emulator i hub: Stopping emulator hub
hoshi-takanori

2021/02/12 23:05

firebase-debug.log というファイルに何か書いてありませんか?
ryota002

2021/02/13 07:12 編集

ご返信ありがとうございます。 debugを確認したところ、JDKがインストールされてないことが原因だったようです。 ありがとうございます。 以下が、現在の状況です。。 ①emulatorはjavaのJDK?インストールしたことで動きました ②emulatorでは、期待した通りの関数が実行されました。 ③しかし、firebase deployを行うと質問文にあったようなエラーが出てしまします、、、
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問