Firebase函数onCreate触发器错误:TypeError:无法读取未定义的属性"match" [英] Firebase Functions onCreate trigger Error: TypeError: Cannot read property 'match' of undefined
问题描述
尝试部署具有针对数据库触发的OnCreate的功能,但它不断向我返回此错误.这是简单的代码和错误响应:
Trying to deploy a function with OnCreate triggered for a database but it keeps returning me this error. Here's the simple code and the error response:
只是无法弄清楚为什么匹配未定义错误?
Just not able to figure out why the match undefined error?
模块版本:
nodejs: Version 8.11.3
Function : deployed with node 8 runtime version.
"firebase": "^5.3.0"
"firebase-admin": "^5.12.1"
"firebase-functions": "^1.1.0"
"typescript": "^2.5.3"
代码:
import functions = require('firebase-functions');
import admin = require('firebase-admin');
exports.functionName = functions.database.ref('/user/{uid}/email').onCreate((snap, context) => {
console.log(snap.val());
});
问题更新:这是最新和最新的代码.我正在尝试获取新添加的对象的详细信息.
Question Update: This is the latest and most updated code. I am trying to get the details of the object newly added.
错误,firebase数据库中向用户添加了一个新元素:
Error there is a new element added to user in firebase database:
TypeError: Cannot read property 'match' of undefined
at resourceToInstanceAndPath (/srv/node_modules/firebase-functions/lib/providers/database.js:154:26)
at dataConstructor (/srv/node_modules/firebase-functions/lib/providers/database.js:122:38)
at Object.<anonymous> (/srv/node_modules/firebase-functions/lib/cloud-functions.js:89:32)
at Generator.next (<anonymous>)
at /srv/node_modules/firebase-functions/lib/cloud-functions.js:28:71
at new Promise (<anonymous>)
at __awaiter (/srv/node_modules/firebase-functions/lib/cloud-functions.js:24:12)
at cloudFunction (/srv/node_modules/firebase-functions/lib/cloud-functions.js:82:36)
at /worker/worker.js:728:24
at <anonymous>
推荐答案
部署时,我遇到了同样的错误:
I had the same error, when i deployed i had this warning:
⚠函数:您必须具有以下版本的firebase-functions版本: 至少2.0.0.请在运行npm i --save firebase-functions @ latest 功能文件夹.
⚠ functions: You must have a firebase-functions version that is at least 2.0.0. Please run npm i --save firebase-functions@latest in the functions folder.
在我安装了最后一个可以正常运行的firebase-functions版本之后.
after i installed the last firebase-functions version it worked.
所以我的解决方法是:
npm i-保存firebase-functions @ latest
npm i --save firebase-functions@latest
这篇关于Firebase函数onCreate触发器错误:TypeError:无法读取未定义的属性"match"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!