question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JSON parsing error when running firebase init

See original GitHub issue

[REQUIRED] Environment info

firebase-tools: 11.0.1

Platform: Windows

[REQUIRED] Test case

  • Install firebase CLI
  • Run firebase init

[REQUIRED] Steps to reproduce

  • Run firebase init inside a project
  • When asked which features to automatically set up, select Firestore: Configure security rules and indexes files for Firestore
  • Enter the default filename for Realtime Database Security Rules (database.rules.json)

[REQUIRED] Expected behavior

A json document containing database rules will be written to the project.

[REQUIRED] Actual behavior

n JSON parsing error occurs.

Logs: ? What file should be used for Realtime Database Security Rules? database.rules.json

[2022-06-05T04:05:03.019Z] >>> [apiv2][query] GET https://<MY-APP>-default-rtdb.firebaseio.com/.settings/rules.json [none]

[2022-06-05T04:05:03.773Z] <<< [apiv2][status] GET https://<MY-APP>-default-rtdb.firebaseio.com/.settings/rules.json 200

[2022-06-05T04:05:03.773Z] <<< [apiv2][body] GET https://<MY-APP>-default-rtdb.firebaseio.com/.settings/rules.json "{\n /* Visit https://firebase.google.com/docs/database/security to learn more about security rules. */\n \"rules\": {\n \".read\": false,\n \".write\": false\n }\n}"

Error: Unable to parse JSON: SyntaxError: Unexpected token / in JSON at position 4

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
bkendallcommented, Jun 13, 2022

This should be resolved in v11.1.0 (which is going out today). Sorry for not getting the fix out sooner.

Duplicate #4596

0reactions
david-potgietercommented, Jun 12, 2022

Workaround I used to get around this. Grab the Realtime DB rules from your console, and create a database.rules.json file manually locally. Remove the comments (as mentioned above) and ensure you have a well formed json and EOF.

Then run firebase init, and say N when prompted if you should overwrite the existing database.storage.rules. Rest of the init completes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: Unable to parse JSON: SyntaxError: Unexpected token ...
Using the --debug argument I've found out that if there isn't a database.rules.json file in the init directory, it will automatically copy ...
Read more >
SyntaxError: Unexpected token/in JSON at position || Firebase ...
I'm trying to deploy a project with firebase init. When I get to the part that asks me this: "What file should be...
Read more >
Troubleshoot initialization options | Firebase - Google
Your application may be using an incomplete or erroneous google-services.json configuration file ; or your app is programmatically initializing Firebase ...
Read more >
Unexpected token u in JSON at position 0 Error in JS
The "Unexpected token u in JSON at position 0" error occurs when we pass an undefined value to the JSON.parse or $.parseJSON methods....
Read more >
SyntaxError: JSON.parse: bad parsing - JavaScript | MDN
JSON.parse() parses a string as JSON. This string has to be valid JSON and will throw this error if incorrect syntax was encountered....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found