前提・実現したいこと
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
あなたの回答
tips
プレビュー