'net::ERR_ABORTED 404 (Not Found) After moving the library files

I was trying to use p5js library, if I put my library into a library folder, the error occurs. But if I put it right next to my script2.js file(where the main program is), it works fine.

This gives error:

<script src="../library/p5.js"></script>
<script src="../library/p5.collide2d.js"></script>
<script src="js/script2.js"></script>

This works fine :(Aftering moving p5.js and p5.collide2d.js to js folder(same as script2.js))

<script src="js/p5.js"></script>
<script src="js/p5.collide2d.js"></script>
<script src="js/script2.js"></script>

I have checked the path for both cases, both should be correct(I ctrl+Left clicked on the paths in VS code and successfully opened the library files) Why is this happening? Any help would be greatly appreciated.

Since Stackoverflow wont let me post images, I'll just paste the path

game\client //this is where index.html located at

game\library //this is where p5.js, p5.collide2d.js located at

game\client\js //this is where script2.js located at

Update: After trying moving the index.html to the top level of the project, which means putting index.html into 'game' folder

and change the path accordingly into this:

<script src="library/p5.js"></script>
<script src="library/p5.collide2d.js"></script>
<script src="client/js/script2.js"></script>   
<script src="/socket.io/socket.io.js"></script>

it still does not work



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source