Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invalid JSON syntax in progressive web app manifest.json file

I get the following error when using the Google Lighthouse extension or other similar manifest.json validation services.

"ERROR: file isn't valid JSON: SyntaxError: Unexpected token in JSON at position 0"

The manifest works. I get the "Add to homescreen" prompt and the manifest.json file is found in dev tools (Application / Manifest section) though the parameters of the file aren't shown.

I've checked the format against the Google IO and that the MIME type is correct. I'm lost as to what else to try.

Any ideas?

like image 228
toepoke.co.uk Avatar asked Dec 14 '22 00:12

toepoke.co.uk


1 Answers

If you're on Windows the above error may be because you have the manifest.json file saved with a Byte Order Mark (BOM).

Saving without a BOM may fix the problem.

In Visual Studio use Save As, use the dropdown next to Save to select Save with Encoding, then pick Unicode (UTF-8 without signature).

like image 54
toepoke.co.uk Avatar answered Dec 16 '22 13:12

toepoke.co.uk