簡體   English   中英

Firebase功能部署錯誤找不到模塊firebase-admin

[英]Firebase function deploy error cannot find module firebase-admin

嘗試將功能部署到Firebase時出現此錯誤。 我已經使用了本教程。 https://firebase.google.com/docs/functions/get-started 在此處輸入圖片說明

我的package.json是這個。

    {
  "name": "functions",
  "description": "Cloud Functions for Firebase",
  "dependencies": {
    "firebase-admin": "^5.4.2",
    "firebase-functions": "^0.7.1"
  },
  "private": true
}

我的index.js是這個

const functions = require('firebase-functions');
// The Firebase Admin SDK to access the Firebase Realtime Database. 
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);

// // Create and Deploy Your First Cloud Functions
// // https://firebase.google.com/docs/functions/write-firebase-functions
//
exports.helloWorld = functions.https.onRequest((request, response) => {
 response.send("Hello from Firebase!");
});
// Take the text parameter passed to this HTTP endpoint and insert it into the
// Realtime Database under the path /messages/:pushId/original
exports.addMessage = functions.https.onRequest((req, res) => {
  // Grab the text parameter.
  const original = req.query.text;
  // Push the new message into the Realtime Database using the Firebase Admin SDK.
  admin.database().ref('/messages').push({original: original}).then(snapshot => {
    // Redirect with 303 SEE OTHER to the URL of the pushed object in the Firebase console.
    res.redirect(303, snapshot.ref);
  });
});

你能告訴我代碼有什么問題嗎? 提前致謝。

您的代碼很好,這是一個Firebase雲功能問題。

我已經解決了:

問題

fwd:同樣的問題。 這是一個火力基地的問題。

自昨天以來,firebase雲服務中斷。

看到這張圖片

問題描述: https//status.firebase.google.com/incident/Functions/17024

問題方案:

在函數庫中運行以下命令:

npm install --save-exact firebase-functions@0.7.0 npm install --save-exact firebase-admin@5.4.0

然后嘗試再次部署功能:

firebase deploy --only functions

我希望這有幫助 :)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM