fluttergoogle-cloud-firestoredeploymentfirebase-cli

Parse error Unexpected token '�' at 1:1 ��{ on flutter app when running firebase deploy


encounter the below message when trying to firebase deploy from root project

Error: Parse Error in ...\firestore.indexes.json Unexpected token '�' at 1:1 ��{

I have a flutter app, upon which I also have a functions folder. Below is the file position:

  1. AppFolder
    • functions
      • .eslintrc.js
      • index.js
      • package.json
      • etc
    • lib
      • files relative to flutter app
    • test
      • test files relative to flutter app
    • web firestore.indexes.json
    • firebase.json
    • etc

I am running on windows 11 in a newly built pc (so maybe sth is missing?), other devs are running on mac, I have changed the EOF sequence to LF on the 3 files of the functions folder, I have also run these two commands inside the functions folder

npm install firebase-functions@latest firebase-admin@latest --save

npm install -g firebase-tools

npm version is 8.1.2

node version is v16.13.1

firestore.indexes.json is:

{
  "indexes": [
    {
      "collectionGroup": "something1",
      "queryScope": "COLLECTION",
      "fields": [
        {
          "fieldPath": "created",
          "order": "DESCENDING"
        },
        {
          "fieldPath": "something2",
          "order": "DESCENDING"
        }
      ]
    },
    {
      "collectionGroup": "something3",
      "queryScope": "COLLECTION",
      "fields": [
        {
          "fieldPath": "something4",
          "order": "ASCENDING"
        },
        {
          "fieldPath": "something5",
          "order": "DESCENDING"
        }
      ]
    }
  ],
  "fieldOverrides": []
}

.elslint.js is

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

and package.json is

  "name": "functions",
  "description": "Cloud Functions for Firebase",
  "scripts": {
    "lint": "eslint .",
    "serve": "firebase emulators:start --only functions",
    "shell": "firebase functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "engines": {
    "node": "14"
  },
  "main": "index.js",
  "dependencies": {
    "axios": "^0.24.0",
    "device-detector-js": "^3.0.0",
    "firebase": "^9.2.0",
    "firebase-admin": "^10.0.1",
    "firebase-functions": "^3.16.0"
  },
  "devDependencies": {
    "eslint": "^8.1.0",
    "eslint-config-google": "^0.14.0",
    "firebase-functions-test": "^0.3.3"
  },
  "private": true
}

Please keep in mind that in an older pc running windows 10 and I can deploy by changing only to the LF and running the above commands.


Solution

  • Just try to make a new text file and copy the content of generated file inside the new one. Then override the new file with firestore.indexes.json

    Its obvious that the generated json file has some formatting problem.