skip to Main Content

I kind of new to node.js
when i run local server with index.js located one directory up from index.htmlthe browser gives me this error:

404 server response

index.js directory up

when i run the server with index.js in the same directory or in a sub folder directory it works fine.

index.js same directory

but i when i run it as live server it works both ways.

I tried moving it to different folders and changing the name.

2

Answers


  1. I’m not sure, but in the first picture index.js seems two directories higher than index.html. Maybe try ‘../../index.js’.

    Login or Signup to reply.
  2. Hi there I found it @Vladislav Bykanov It is because index.html and app.js or in your case index.js should be on the same level of hierarchy i.e
    Such as in the given image… Here js file and HTML file are on same level… App.js is now as /app.js only… it is not ../public/app.js

    I am suggesting you not to put index.html in public and put it in the normal ../index.html so that it doesn’t confuse you…

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search