【问题标题】:Firebase function deploy error cannot find module firebase-adminFirebase 功能部署错误找不到模块 firebase-admin
【发布时间】:2018-03-31 04:16:11
【问题描述】:

我在尝试将功能部署到 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);
  });
});

你能告诉我代码有什么问题吗?提前致谢。

【问题讨论】:

    标签: node.js firebase google-cloud-functions


    【解决方案1】:

    您的代码很好,但它是 firebase 云功能问题。

    我已经解决了:

    issue

    转发: 这里同样的问题。这是一个火力基地问题。

    从昨天开始,Firebase 云服务出现中断。

    see this image

    问题描述: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
    

    我希望这会有所帮助:)

    【讨论】:

    • 哇,它成功了。你是救生员。非常感谢。
    猜你喜欢
    • 2018-03-31
    • 1970-01-01
    • 2019-12-12
    • 2020-07-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-16
    相关资源
    最近更新 更多