Whenever I start my NodeJS server and enter localhost:8080
, I encounter the mentioned error while the page is loading. The head section of my index.html
file is provided below. It's puzzling to me why this error is happening, considering that my index.html
is located in the same directory as script.js
and style.css
.
<head>
<meta charset="utf-8">
<title>Experimenting with Express and Node</title>
<link rel="stylesheet" href="style.css" type="text/css" />
<script src="script.js" type="text/javascript"></script>
</head>
The code snippet below is from my app.js
file, used for routing in ExpressJS.
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, "/web/index.html"));
});
Despite extensive searching for a solution, I haven't been able to resolve this issue on my own. That's why I've turned to seeking help on StackOverflow. Any assistance given would be highly valued.