小编Abe*_*emi的帖子

错误:部署谷歌云功能时找不到模块“firebase/app”

基本上我试图让 firebase 函数简单地在文档中输出值,我只在本地实现了这一点......但该函数不会部署到云。下面是函数

\n\n
const functions = require(\'firebase-functions\');\nconst firebase = require(\'firebase/app\');\nrequire(\'firebase/firestore\');\n\nconst firebaseConfig = {\n    projectId: "covid-info-bw"\n};\n\nconst db = firebase\n.initializeApp(firebaseConfig)\n.firestore()\n\n// // Create and Deploy Your First Cloud Functions\n// // https://firebase.google.com/docs/functions/write-firebase-functions\n//\nexports.helloWorld = functions.https.onRequest((request, response) => {\n  response.send("Hello from Firebase! Dawg I am beast");\n});\n\n\nexports.getData = functions.https.onRequest((req, res) => {\nconst docRef = db.collection(\'FunctionTest\').doc(\'Cm38kBYShNnyuLVpizcy\');\nconst getDoc = docRef.get()\n    .then(doc => {\n    if (!doc.exists) {\n        console.log(\'No such document!\');\n        return res.send(\'Not Found\')\n    } \n        console.log(doc.data());\n        return res.send(doc.data());\n    })\n    .catch(err => {\n    console.log(\'Error getting document\', err);\n});\n
Run Code Online (Sandbox Code Playgroud)\n\n

这是 package.json …

javascript firebase google-cloud-platform google-cloud-functions google-cloud-firestore

0
推荐指数
1
解决办法
1013
查看次数