如何修复'解析错误:节点中的意外标记=&>&39;? [英] how to fix 'parsing error: Unexpected token =>' in node?

查看:19
本文介绍了如何修复'解析错误:节点中的意外标记=&>&39;?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Firebase函数进行条带支付集成。此特定功能用于使用条带注册客户。

节点版本10.15.3,

NPM版本6.9.0,

"ecmaVersion":.eslintrc.json中的6

const functions = require('firebase-functions');

const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);

const stripe = require('stripe')(functions.config().stripe.testkey)

exports.createStripeCustomer = functions.auth.user()

          .onCreate(async (user) => {
             const customer = await
             stripe.customers.create({email: user.email});
             await admin.firestore()
               .collection('stripe_customers')
               .doc(user.uid)
               .set({customer_id: customer.id});

           });

代码与GitHub示例中提供的FireBase平台相同 https://github.com/firebase/functions-samples/blob/master/stripe/functions/index.js

分析错误:意外令牌=>

如果我在.eslintrc.json中将"ecmaVersion":6更改为"ecmaVersion":8

then error is .onCreate(async (user) => {

                            ^

SyntaxError: Unexpected token (

我希望正确部署功能,以便用户可以在Firebase存储中条带和日期存储上注册

推荐答案

确保您在本地计算机节点>=8上运行。要进行部署,您的Package.json中应该有。

{
    //...
    "engines": {
        "node": "8"
    },
    //...  
}

对于eslint,要启用对异步函数的解析,您应该在配置中包括以下内容:

{
    "parserOptions": {
        "ecmaVersion": 2017
    }
}

这篇关于如何修复'解析错误:节点中的意外标记=&>&39;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆