For some reason I am getting this issue and I am not sure why. I've done stuff like this before, but now when I am connecting a javascript file to my HTML it is reading incorrectly. Here is the exact issue: My current running directory is
-> public
->js
-app.js
-particles.js
-particles.json
-index.html
-index.css
My HTML is
<body>
<header>
</header>
<main>
<h1>Hi my name is Bob</h1>
<div id="particles-js"></div>
<!--
<div class="footer">
<div class="footer-contents">
<div id="info"> Designed and Developed by Jasmin Adzic</div>
<div id="links"> more info</div>
</div>
</div> -->
<script type="text/javascript" src="js/particles.js"></script>
<script type="text/javascript" src="js/app.js"></script>
</main>
<footer>
</footer>
</body>
and in the browser I get these errors
I can get all this to work if I move every file from the js directory into the public directory and get rid of the js/ in front of the src inside the script tags, but for some reason when I put the files inside another directory and try to access the files inside the directory using script src the browser thinks i am trying to access jsparticles.js instead of js/particles.js. That is what i believe is my error.
I tried researching why this is happening and yes I did look at many similar stack overflow questions but haven't had any luck finding a solution.
Ok here are the javascript files. Keep in mind im running a local server using node.js
app.js (which is running on the server)
var fs = require('fs');
var http = require('http');
var static = require('node-static');
var url = require('url');
function static_handler(req, res) {
req.addListener('end', function() {
fileServer.serve(req, res, function (e, result) {
console.log("NOT FOUND");
});
}).resume();
}
function createMessage(theList) {
console.log(theList);
console.log(theList.length);
console.log(typeof theList);
var message = "";
for(var i = 0; i < theList.length; i++) //need to put this in a callback function cus servers run syncronously
{
message += theList[i];
}
return message
}
function handler(req, res) {
console.log("request url issss " + req.url);
var url = req.url;
if (url != '/favicon.ico')
{
url = url.replace('/','');
url = url.split('/');
console.log(url);
console.log(url.length);
console.log(typeof url);
if(url.length >= 2)
{//dynamic meaning we dont load up a static page
res.writeHead(200, {"Content-type": "text/plain"});
// var message = (url) => {for(var i = 0; i < url.length; i++) //need to put this in a callback function cus servers run syncronously
} return message};
var message = createMessage(url);
res.write(message);
res.end();
}
if(url.length == 1)
{
console.log("ready for next shizzz");
fileServer = new static.Server('./public');
static_handler(req,res);
}
}
}
var server = http.createServer(handler);
server.listen(port);
app.js and particles that is in the js folder is given straight from github:
https://github.com/VincentGarreau/particles.js/tree/master/demo/js
and so is particles.js
https://github.com/VincentGarreau/particles.js/blob/masteenter code herer/particles.js
(I would've included code snippets but it exceeded the character limit on the post)

src="./js/particles.js".works. Do thissrc='/js/particles.js'