简体   繁体   中英

why doesn't my live server work in visual studio code?

实时服务器的图像

My live server on visual studio keeps opening an old html file when i try to open my current one. Ive tried reinstalling the extension but its the same problem. Can anyone help please

i cannot have two project folders with an html file running through the live server. Only one html file can be streamed at one time other wise when trying to stream the second, it will stream the first (Like the issue i was having)

I was having the same problem but later on I find out that, I renamed my project folder while my server was still loading the same project but with the previous folder name so I changed the link to my new folder folder name and it worked for me.

I have live server will simply not work if there was an error in JavaScript file.

Even if you do an alert in the beginning of JavaScript file (for test purposes) but at the end of the file re-define a variable which was already defined before, this error will render liver server not working.

The html page will not respond as well.

Solution is to go to developer tools (F12), see the errors on console, fix them and save and the live server would be back in action. At least that was the case with me.

I had the same issue, sometimes it was an error on the console, or keep showing an old HTML, tried everything, deleting cookies, reinstalling everything and nothing worked,

Eventually, it worked with a hard refresh, what it really worked was to

Go to ---> vs code settings ----> extensions ---> live server config set as chrome private. So far no more errors!

在此处输入图像描述

The liveserver extension serves static pages like html files and it does not load javascript or typescript files. You need to setup a server yourself for example in react you use webpack to configure your local server and your app runs on a localhost:port. In a nutshell, you need to write a script for node to run your js files. And you won't need liveserver after that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM