When I run the live server, it basically points to the default directory instead of letting me choose on which file to run the live server. I need a way such that i can get to choose which file to run on the live server(ie it may be saved anywhere on my computer and I should be able to run it!).
There is a settings liveServer.settings.root to change root from work-space root directory to anywhere else (but it should be inside of work-space).
https://github.com/ritwickdey/vscode-live-server/blob/master/docs/settings.md
I figure it's the best place to mention the following issue:
@ritwickdey The option you are mentioning only works in the main vscode settings, but not in the project settings which is kind of odd since you are going to have a different root for each project ... I guess.
@SylannBin You can configure settings for each project separately by create .vscode (folder) > settings.json and overwrite settings for that project
@ashishgupta1350 @SylannBin I am closing this issue if still have this issue then reopen it.
Hi, sorry to ask, but I do not understand how to change the settings. I see a list of settings under "Contributions" but cannot actually make any changes there. Please advise! Thank you.
@cohn17 I had some issues too. What I did was:
.vscodesettings.json{
"liveServer.settings.root": "/dist"
}
(dist being the root folder I want the liveserver to know about)
Then I actually had to edit the global settings.json:


From now on, liveserver seems to follow whatever is written in the /.vscode/settings.json - file. Perhaps a bug in vscode?
how do you do this on mac I cannot make a .vscode folder with a "." as the first character.
@cohn17 I had some issues too. What I did was:
- Create a folder under the root of the site, called
.vscode- Add a file there, called
settings.json- Edit the file and add the following:
{ "liveServer.settings.root": "/dist" }(
distbeing the root folder I want the liveserver to know about)Then I actually had to edit the global settings.json:
- CTRL+SHIFT+P and type "Preferences".
- Search for "liveserver" and click "Edit in settings.json"
- I then added the same code inside my global settings.json:
- Then launched liveserver, killed it, removed the setting in the global settings.json and then relaunched the server.
From now on, liveserver seems to follow whatever is written in the /.vscode/settings.json - file. Perhaps a bug in vscode?
Thankss!
Hi,
I am new to VS Code so sorry for dummy question.
What if for learning purposes I have a few different folders with the same structure inside with different lessons (versions of the sites) and I need to switch from one to another inside the same Workspace? Let's say I opened one index.html inside one of the folders inside root of my Workspace and launched it with the Live Server. Then I need to go to another folder inside my Workspace root and to open another index.html inside that separate folder. I open it up in the Live Server but there is still the previous site version opened again.
Is there a way to set it up in the way that it would open up the files from the currently selected folder inside my Workspace (from the folder where currently active file is located in and its subfolders)?
Most helpful comment
There is a settings
liveServer.settings.rootto change root from work-space root directory to anywhere else (but it should be inside of work-space).https://github.com/ritwickdey/vscode-live-server/blob/master/docs/settings.md