Search code examples
google-chromegoogle-chrome-extensionchrome-web-store

Error on publishing Chrome Extension


I Have develop a Chrome extension but I'm stuck in the publishing step... When I try to upload my extension, I get this error :

An error occurred: Failed to process your item.
The manifest must define a version.

But I have defined a version... Here my manifest.json file :

{
    "manifest_version": 2,
    "name": "AccessID - RFID",  // Nom
    "version": "0.0.0.1",  // Version
    "version_name": "0.1 Beta",

    "description": "Gestion RFID.", // Description

    "icons": { ... },

    "permissions": [ ... ],

    "options_ui": { "page": ... },

    "background":
    {
        "scripts": [ ... ]
    },

    "content_scripts" :
    [
        {
            "matches": [...],
            "all_frames": true,
            "js": [ ... ],
            "css" : [ ... ]
        },
        {
            "matches": [ ... ],
            "all_frames": true,
            "js": [ ... ]
        }
    ],

    "web_accessible_resources" : [ ... ],

    "page_action":
    {

        "default_title": "",
        "default_popup": "",
        "default_icon": { ... }
    }
}

The most weird thing is that it's working great in developement mode. The extesnion is loaded and works well. So I actually don't understand what is going on.


Solution

  • manifest.json, as the name implies, is a JSON (JavaScript Object Notation) file and not a JavaScript source file.

    The JSON format is deliberately simplistic and does not support any form of comments - so technically they are a syntax error. It's strange that it loaded normally for development, though.

    Removing // comments will fix your issue. Other common issues include forgetting to put keys into quotation marks and leaving an extra comma - JavaScript would not complain about this since it's a valid ECMAScript object literal, but it's invalid JSON.

    You can use JSON validators like JSONLint to catch errors like this.