4

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.

2
  • Can you change the "lint": "eslint ." line to "lint": "eslint" in package.json and see if that resolves the issue? Commented Dec 31, 2021 at 12:09
  • I already did that, it did not change anything Commented Jan 7, 2022 at 10:12

3 Answers 3

10

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.

Sign up to request clarification or add additional context in comments.

2 Comments

This actually solved my problem, thanks!
Yeah, I can see the file contents have special characters after pulling the contents down via CLI from Firebase, how strange. File starts like this: ��{. Anyway copying content to a new file worked, thanks.
1

Try creating a new file with the name firestore.indexes.json and copy the contents, that worked for me.

Comments

0

I recently had this problem and found that it was resolved by changes to the firebase.json file:

Seek "predeploy":

Delete the code so that the outcome is "predeploy": []

After this, run the firebase deploy function again, and everything should be fine.

Thank you to Max for sharing this solution with me : )

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.