Uncaught SyntaxError: Unexpected token <

created at 07-11-2021 views: 30


When I was writing the code today, I found the js error of "Uncaught SyntaxError: Unexpected token <" <html>, and it was still the first line of html. I was blinded. What's wrong with this first line? There is also a < Symbol, I thought it was because my webpage tag had no closure, so I checked it and it was not! The error is shown in the figure.

Uncaught SyntaxError: Unexpected token <

Later, after investigation, it was discovered that this SyntaxError is definitely a js error! Haha, what's wrong? First of all, I checked the introduction of js and found that there was a line of js introduction error. Fortunately, I clicked one by one to see if js can be clicked. That's it.

<script type="text/javascript" src="/static/h-ui.admin/js/H-ui.admin.page.js"></script>


I found that the above js import path cannot be opened normally, so I changed it to the correct js path, as follows.

<script type="text/javascript" src="/asset/static/h-ui.admin/js/H-ui.admin.page.js"></script>

Sure enough! No more Uncaught SyntaxError: Unexpected token < error, solved perfectly!

My suggestion: If the import path is correct, then there must be a problem with the JavaScript method, and then check whether the method uses an undefined function or the like, it's ok, easy!

created at:07-11-2021
edited at: 07-11-2021: