Access the extended background.js console and development tools
P粉983021177
P粉983021177 2023-08-27 17:50:24
0
2
547
<p>I just started using the Google Chrome extension and I can't seem to log into the console from the background js. I also can't find any error message when an error occurs (e.g. due to a syntax error). </p> <p>My manifest file:</p> <pre class="brush:php;toolbar:false;">{ "name": "My First Extension", "version": "1.0", "manifest_version": 2, "description": "The first extension that I made.", "browser_action": { "default_icon": "icon.png" }, "background": { "scripts": ["background.js"] }, "permissions": [ "pageCapture", "tabs" ] }</pre> <p>background.js:</p> <pre class="brush:php;toolbar:false;">alert("here"); console.log("Hello, world!")</pre> <p>When I load the extension, the alert appears, but I don't see anything logged to the console. What did i do wrong? </p>
P粉983021177
P粉983021177

reply all(2)
P粉211600174

I had the same issue, in my case the logging in the console tab of Chrome Developer Tools was set to "Hide All". I didn't even realize this was an option and I don't remember turning it off

P粉916760429

You are looking at the wrong place. These console messages do not appear in the web page, but appear in an invisible background page (ManifestV2) or Service Worker (ManifestV3).

To see the correct console for background script context open the development tools:

  1. Visit chrome://extensions/ or right-click the extension icon and select "Manage Extensions."
  2. Enable developer mode
  3. Click the link named Background Page (ManifestV2) or Service Worker (ManifestV3).

Screenshot of ManifestV2 extension:

Screenshot of ManifestV3 extension:

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template