. Advertisement .
..3..
. Advertisement .
..4..
Good day, everyone! I am having problem with error “Uncaught SyntaxError: Unexpected token ‘<‘ “. I would like to get your advices on this matter.
When I was trying to start a Javascript program today, a message with the following text appeared on my screen:
Uncaught SyntaxError: Unexpected token '<'
This is my program:
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
</head>
<body>
<!-- ⛔️ Uncaught SyntaxError: Unexpected token '<' ⛔️ -->
<script src="index.html"></script>
</body>
</html>
As a newcomer to this field, I’m confused by this issue and have spent much time trying to figure it out. Please help me in finding answers to this issue.
Cause: After looking over your program, I discovered that instead of a JS file, your script tag links to an HTML file. This is why the warning message “Uncaught SyntaxError: Unexpected token ‘<‘ ” appears.
Solution: Let’s check that any script tags you’re using point to a valid path and ensure that the names of your files are written in lowercase letters. The issue may occur if the file name contains capital letters or uncommon characters. If you follow the steps outlined above, the issue you’re having will be resolved effectively.