Open index.html but it turns out undefined

Viewed 55

I am a beginner of JS, I usually use live server in VS code to see if my code works properly. A weird thing happens to a project, when I run the live server, the path becomes undefined, then the website crashed. I tried to open the file from the file manager, the same situation.

My original filename: file:///D:/Desktop/trashcar/index.html When it opens on the browser: file:///D:/Desktop/trashcar/undefined

I am not sure if I accidentally change the settings, and the unexpected thing is only in this project. I've tried to search possible cases, but it seems I am the first case. I will be thankful if someone can give me a hint on this.

2 Answers

Just set the pathname in your browser to file:///D:/Desktop/trashcar/index.html

You don't need a server to view static HTML.

I tried to create a new file and past the original code line by line and it fix now. I still wonder why this happens only to that file.

Related