您好,我在使用javascript在firebase中部署函数时遇到错误

您好,我在使用javascript在firebase中部署函数时遇到错误,javascript,google-cloud-functions,Javascript,Google Cloud Functions,.eslintrx.js module.exports={ 根:是的, 环境:{ 是的, 节点:对, }, 扩展:[ “eslint:推荐”, “谷歌”, ], 规则:{ 引号:[“错误”,“双精度”], }, }; index.js let functions = require('firebase-functions'); let admin = require('firebase-admin'); admin.initializeApp(); exports.onConversati

.eslintrx.js

module.exports={
根:是的,
环境:{
是的,
节点:对,
},
扩展:[
“eslint:推荐”,
“谷歌”,
],
规则:{
引号:[“错误”,“双精度”],
},
};
index.js

let functions = require('firebase-functions');
let admin = require('firebase-admin');

admin.initializeApp();

exports.onConversationCreated;
onConversationCreated = functions.firestore.document("Conversations/chatID").onCreate((snapshot, context) => {
    let data = snapshot.data();
    let chatID = context.params.chatID;
    if (data) {
      let members = data.members;
      for (let index = 0; index < members.length; index++) {
        let currentUserID = members[index];
        let remainingUserIDs = members.filter((u= string) => u !== currentUserID);
        remainingUserIDs.forEach(async (m= string) => {
          try {
            let _doc = await admin.firestore().collection("Users").doc(m).get();
            let userData = _doc.data();
            if (userData) {
              return admin.firestore().collection("Users").doc(currentUserID).collection("Conversations").doc(m).create({
                "chatId": chatID,
                "image": userData.image,
                "name": userData.name,
                "unseenCount": 0,
              });
            }
            return null;
          } catch (e) {
            return null;
          }
        });
      }
    } return null;
  });

我的处境和你一样,所以我把我的快速解决方案留给你。 预部署时“run lint”会导致错误,
意外标记=>
,但我们都知道这不是错误

解决方案

  • 清除
    .eslintrx.js
    后,它将工作

  • 删除
    firebase.json
    文件中的一些行

    firebase.json
    文件中

  • 在github线程中查找更多信息:
  • 你能试试吗。看起来是同一个问题。
        ...
          "functions": {
            "predeploy": [
              "npm --prefix \"$RESOURCE_DIR\" run lint"  << DELETE THIS LINE
            ]
          }
    
      env: {
        es6: true, -> es2017 or higher?? will it work??
        node: true,
      },