Manifest is not valid JSON. Line: 1, column: 1, Unexpected token

前端 未结 10 1280
小鲜肉
小鲜肉 2020-12-09 08:31

keep getting this error: \"Manifest is not valid JSON. Line: 1, column: 1, Unexpected token.\" i don\'t understand what the issue is with my code? here is what i have so f

相关标签:
10条回答
  • 2020-12-09 08:48

    Please try to save the manifest.json file as UTF8 format.

    0 讨论(0)
  • 2020-12-09 08:53

    The browser cannot find the manifest because the extension (MIME type). In Chrome DevTools > Network > Headers > Content-Type, the content-type of the manifest must match the actual manifest file extension (.json or .webmanifest). To resolve the 404 error, you need to declare the file type in web.config:

    <staticContent>
      <mimeMap fileExtension=".json" mimeType="application/json" />
      <mimeMap fileExtension=".webmanifest" mimeType="application/manifest+json" />
    </staticContent>
    
    0 讨论(0)
  • 2020-12-09 09:00

    This is old but I had the same issue and found out I was not using the standard double quotes " in my script which I copied and pasted from the official Google Doc

    0 讨论(0)
  • 2020-12-09 09:02

    In my particular case, I had this added in my manifest.json:

    "storage": {
       "managed_schema": "storage.json"
    }
    

    But my storage.json was empty. I had to edit my storage.json file with this content:

    {
       "$schema": "http://json-schema.org/draft-03/schema#",
       "type": "object",
       "properties": {
          "adminSettings": {
             "title": "A valid JSON string compliant with backup format.",
             "description": "All entries present will overwrite local settings.",
             "type": "string"
          }
       }
    }
    

    But in general, here's my advice when you get this Line 1 Col 1 Unexpected Token misleading error that basically translates to: Something is wrong in one or more sections of your JSON and may or may not have anything to do with syntax in this file.

    1. Move the most common, simple string things to the top of your manifest.json file such as manifest_version, name, description, etc.
    2. Put the more elaborate array things towards the bottom, starting with the one you most suspect might be the problem.
    3. Save the file as UTF-8.
    4. Then, run it through an online validator.
    5. From there, if you still get the problem, then use another notepad and cut/paste items from the bottom of your JSON into another text file and try to upload your JSON again. (Note, you'll likely get an error of ending your JSON block with a comma with no following item. So, don't forget to undo that when you get an error.)
    6. Anyway, repeat step 4 until finally that Line 1 Col 1 error goes away. At that point, you know the offending section that you need to deal with.
    7. Paste everything else back except that section back into your manifest.json. This is how I found out that my storage block was the problem. I looked at another Chrome Extension to see how they did things and realized my error.
    0 讨论(0)
提交回复
热议问题