分析错误:尝试部署Firebase云函数时意外令牌=>;。我在这里找不到任何答案 [英] Parsing error: Unexpected token => when trying to deploy firebase cloud function. I couldn't find any answers on here
本文介绍了分析错误:尝试部署Firebase云函数时意外令牌=>;。我在这里找不到任何答案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
exports.sendInvite = functions.firestore
.document("invites/{phoneNumber}")
.onCreate(async (doc) => { //error is here I assume
const from = "+<mynumber>";
const to = doc.data().phoneNumber;
const text = "You can join the club now";
return client.messages.create(from, to, text);
});
我的.eslintrc.js
module.exports = {
root: true,
env: {
es6: true,
node: true,
},
extends: [
"eslint:recommended",
"google",
],
rules: {
quotes: ["error", "double"],
},
};
我的Firebase云函数抛出此错误Parsing error: Unexpected token =>
。
有人知道为什么会发生这种事吗?我使用的是javascript btw,不是TS。
ES3>推荐答案
箭头函数是ES6的一项功能,但这里有一个异步箭头函数。
异步功能通常是ES8(或2017)功能。因此,您需要在配置的根目录下指定以下设置:
parserOptions: {
ecmaVersion: 8 // or 2017
}
这将让分析器知道在使用async
之后需要=>
标记。
这篇关于分析错误:尝试部署Firebase云函数时意外令牌=>;。我在这里找不到任何答案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文