首页 > 解决方案 > Firebase Deploy 在“=>”上获取解析错误

问题描述

当我进入 firebase deploy --only 功能

终端与我的代码存在问题:

amazon-clone-app\amazon-clone\functions\index.js 18:55 错误解析错误:意外令牌 =>

这是我的 eslintrc.js 文件:

module.exports = { 
 root: true,
 env: {
  es6: true,
  node: true,
 },
 extends: [
  "eslint:recommended",
  "google",
  ], 
  rules: {
   quotes: ["error", "double"],
  },
};

这是我在终端报告错误函数处的 index.js 文件:

app.post("/payments/create", async (request, response) => {
  const total = request.query.total;
  const paymentIntent = await stripe.paymentIntents.create({
     amount: total,
     currency: "usd",
  });

  response.status(201).send({
     clientSecret: paymentIntent.client_secret,
  });
});

标签: firebaseparsing-error

解决方案


希望这对你有用,就像对我自己一样。在 firebase.json 文件中,您必须将其更改为此。将 % 添加到这个 "%$RESOURCE_DIR%. 之后,firebase deploy --only 功能起作用。

 "functions": {
    "predeploy": [
      "npm --prefix \"%$RESOURCE_DIR%\" run lint"
    ],

推荐阅读