menu

Questions & Answers

Can't load background script - manifest.json - Angular Chrome Extension

I'm a beginner programmer and I will gladly accept good advice from experienced colleagues. I write my chrome plugin, but I encountered a problem with the background script attachment. When installing the plugin, there is a problem that informs in free translation that the "background.js' script operating in the background failed to load. You can't load the manifest file.

I tried to change background.js file content, its name, location. Add permissions, script types, I looked through all possible guides and solutions, but the script loading error still occurs, even with an empty background.js. Ofcourse manifest.json and background.js are in the same location.

Manifest.json file: { "manifest_version": 3, "name": "firstExt", "description": "My first extension", "version": "0.1", "background": { "service_worker": "background.js", "type": "module" }, "minimum_chrome_version": "92", "permissions": [ "storage", "activeTab", "scripting", "contextMenus"], "action": { "default_popup": "index.html" }, "host_permissions": [ "http://*/*", "https://*/*", "://*/" ] }

Answers(1) :

Try this very simple background script and I think it will clarify your problem.

enter image description here

manifest.json

{
  "name": "service_worker",
  "version": "1.0",
  "manifest_version": 3,
  "background": {
    "service_worker": "background.js"
  }
}

background.js

console.log("background.js");