Open dvsoukup opened 6 years ago
Assuming you are using the command to start live-server from the root directory of your project, you can prepend the HOME environment variable that will then be picked up by live-server. This will allow the .live-server.json
file is to be correctly located and processed. I use a script in my package.json
for this purpose:
{
"scripts": {
"dev": "HOME=./ node_modules/.bin/live-server"
}
Before submitting an issue, please, see https://github.com/tapio/live-server#troubleshooting
Issue description
Currently I operate on WSL (Windows Subsystem for Linux), with ubuntu. During some project setup stuff, I opted to use live-server to serve out some html pages for a SPA I'm building.
Anyhow, per the documentation, it states that having a
.live-server.json
in the root of your project will utilize those values as a part of launching live-server. This failed time and time again though, and it did NOT consume the values in that JSON.Software details
Command line used for launching
live-server
:./node_modules/.bin/live-server
OS: Windows 10, but using Ubuntu 16.04 on WSL
Browser (if browser related):
Node.js version: 10+
live-server
version: live-server 1.2.0Other notes: In an attempt to just get this working locally, I wound up figuring out the issue here. So I have my VSCODE source files on the "windows" side, under the C drive. When using WSL, that C drive is technically mounted to
/mnt/c/Users/me/path/to/project
. However, the logic within live server checks which OS you're operating on, per line 17 oflive-server.js
:var homeDir = process.env[(process.platform === 'win32') ? 'USERPROFILE' : 'HOME'];
For me it says I'm using a linux based system, thus it pulls in
/home/me
as the base directory to join to the.live-server.json
file. Which is 100% wrong. I temporarily modified my locallive-server.js
to change it from:to:
This made it correctly consume my .json settings! Obviously this is a simple hack. I think there instead ought to be some sort of command line parameter to specify the path to where the
.live-server.json
file resides. If that command is ommitted, then just default to this current implementation of determining a users home directory. If the command is there, then traverse that path to read the .json file.Would be useful to have a command such as:
live-server --config=PATH
, wherePATH
is the absolute path to where the.live-server.json
file resides.There might be better options but this is just a quick 5 min assessment of a way to solve this problem, so don't take this as "this is the way it must be done".