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

前端 未结 10 1279
小鲜肉
小鲜肉 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:36

    I had my manifest.json File Properties set with Build Action: None, in Visual Studio 2010.

    Changing, in Visual Studio, to Content ensured the file was transferred when I deployed.

    Maybe yours is a similar issue.

    Edit

    Given my downvote I thought I should expand and say that my point was that, given that at line 1, column 1 there is valid json, it is more likely that you are getting a 404 http response than the actual json file returned.

    So maybe the file isn't in the correct place or the server doesn't have permissions or whatever but the above is what had gone wrong with mine. Admittedly it is maybe too specific to what had gone wrong with mine and not definitely what was wrong with yours.

    But the general point still stands, it's more likely caused by web server returning an http response for the json file, check the response in the network log in your browser.

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

    I added crossorigin attribute its worked.

    <link rel="manifest" crossorigin="use-credentials" href="%PUBLIC_URL%/manifest.json" />
    
    0 讨论(0)
  • 2020-12-09 08:38

    This error also occurs when manifest is empty, or there is no manifest at all. If u use some framework, eg. Angular, just check whether you have manifest in your production build. If not - add "manifest.json" in your angular.json/angular-cli.json to assets array.

    Example: "assets": ["assets", "favicon.ico", "manifest.json"]

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

    It seems your are using wrong values for browser_action key.To specify popup template you must use default_popup. It should be :

    {
      "manifest_version": 2,
      "name": "extension",
      "version": "1.0",
      "description": "My first Chrome extension.",
      "browser_action": {
          "default_icon": "icon.jpg",
          "default_popup": "popup.html"
      }
    }
    
    0 讨论(0)
  • 2020-12-09 08:41

    Content-type

    Check the Content-Type of manifest.json in the Network tab. This needs to be application/json instead of text/html.

    If you have wrong content-type, you may need to configure the settings of your webserver to correctly serve json files.

    In my case I had to add it to the nginx sites-enabled file:

    location ~* .(jpg|jpeg|gif|png|css|js|ico|xml|svg|json)$

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

    I know this is an old question but just in case the accepted answer above doesn't work for someone be sure to check the spelling of and path to the manifest.json are correct. I previously got the same error from a simple typo. Simple mistake but it happens!

    0 讨论(0)
提交回复
热议问题