admin管理员组

文章数量:1296843

Why is my background.html page throwing this:

Uncaught SyntaxError: Unexpected token < in line 1

Here is the actual html:

<html>
<head>
<script type="text/javascript" src="fancy-settings/source/lib/store.js"></script>
<script type="text/javascript" src="background.js"></script>
</head>
<body></body>
</html>

So chrome plains about the first opening "<" and I have no idea why.

Why is my background.html page throwing this:

Uncaught SyntaxError: Unexpected token < in line 1

Here is the actual html:

<html>
<head>
<script type="text/javascript" src="fancy-settings/source/lib/store.js"></script>
<script type="text/javascript" src="background.js"></script>
</head>
<body></body>
</html>

So chrome plains about the first opening "<" and I have no idea why.

Share Improve this question asked Apr 25, 2012 at 12:25 KaiKai 2,3253 gold badges32 silver badges44 bronze badges 3
  • 6 Are you sure that the plaint is about this file and not one of the .js files? – Mr Lister Commented Apr 25, 2012 at 12:30
  • Sounds like a JSON parsing error. That's at least what one would look like. Are you sure none of the JavaScripts loads/parses a file that is expected to be JSON? – Tharabas Commented Apr 25, 2012 at 12:35
  • Can you include your manifest.json file contents? – Mihai Parparita Commented Apr 27, 2012 at 17:11
Add a ment  | 

3 Answers 3

Reset to default 6

I had the same issue. Just replace in your manifest.json file

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

with:

"background": {
    "page": "background.html"
  },

remove js:

<script type="text/javascript" src="fancy-settings/source/lib/store.js"></script>
<script type="text/javascript" src="background.js"></script>

If the error persists, then you are not hooked up correctly js

If you are using Manifest V3, just add type: "module" in the background

     {
        ...
        "background": {
        "service_worker": "background.js",
        "type": "module"
        },
        ...
     }

本文标签: