Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
23
rated 0 times [  29] [ 6]  / answers: 1 / hits: 20690  / 3 Years ago, mon, july 19, 2021, 12:00:00

I'm getting a very strange issue.
When I open index.html(see below) in the browser, The DOM elements are rendering correctly, but I'm getting this console error:


Uncaught SyntaxError: Unexpected token '<'


To make sure the error is not coming from any code in my JavaScript, I emptied my JavaScript file so it had no code in it. So this is not any "code-in-javascript" related issue

What is it?


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>HAHAHA</h1>
<script type="text/javascript" src="./src/index.js"></script>
</body>
</html>

More From » html

 Answers
9

Finally I figured out the error. I was using npm live-server package. When I used live-server provided by vs-code as an extension, the issue is gone.
It's working perfectly fine now.


[#50233] Wednesday, June 16, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
mckinleyk

Total Points: 730
Total Questions: 99
Total Answers: 99

Location: South Georgia
Member since Fri, Nov 13, 2020
4 Years ago
;