Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

What should i do to replace this old manifest v2 code for manifest v3 for Google Chrome Extenion [duplicate]

Ask Question Chrome extensions: Use the "background.service_worker" key instead manifest_version 3 (1 answer)
Closed 8 months ago .

This post was edited and submitted for review 8 months ago and failed to reopen the post:

Original close reason(s) were not resolved

So I am making an extension and I am using a template from an old youtube video that uses manifest v2 and I am using manifest v3 but how do I exchange this code

"background": {
    "service_worker":
        "popup.js",
        "persistent": true

The error I get from chrome is this

Failed to load extension
File: ~/Chrome extenions /BackgroundChanger
Error: The "background.persistent" key cannot be used with manifest_version 3. Use the "background.service_worker" key instead.
Could not load manifest.

I expected manifest v2 and v3 should be at least similar

The migration guide can be found here: https://developer.chrome.com/docs/extensions/mv3/mv3-migration/.

The error you get specifically is caused by having a scripts property in the background object. It should be replaced with "service_worker": "popup.js".

Thanks that worked but now i am getting this error Failed to load extension File ~/Chrome extenions /BackgroundChanger Error The "background.persistent" key cannot be used with manifest_version 3. Use the "background.service_worker" key instead. Could not load manifest. – Stephan Teig Oct 27, 2022 at 9:02 Just remove persistent property - it is not necessary as for V3 it terminates when not in use. – Aid Hadzic Oct 27, 2022 at 9:09