live-server icon indicating copy to clipboard operation
live-server copied to clipboard

Live server can't be run from a relative project directory.

Open briancullinan2 opened this issue 5 months ago • 0 comments

Before submitting an issue, please, see https://github.com/tapio/live-server#troubleshooting

Issue description

Live-server requires an absolute path for root.

Software details

  • Command line used for launching live-server:
  • OS: NPM
  • Browser (if browser related): Chrome
  • Node.js version: v22.5.1
  • live-server version: live-server 1.2.2

Basic example

  1. run npm init inside your project.
  2. run npm install live-server to add it as a dependency to package.json
  3. put this script in package.json "start": "live-server --root=docs" or rename docs to a project within your project directory.
  4. run npm start

This is how I expect the NPM live-server, as a developer, to use live server. This is how I want to use live-server, this is how I want to start it. This is how I want other people to be able to start my server. My instructions for other people using my project are npm install and npm start.

Outcome

Live server starts in a directory relative to the root of my system /docs/

Expected

Live server to append the --root path to $(cwd) internally when one directory exists and the other directory does not exist

Currently, there is no way described in the instructions to launch live server with a path relative to my project, and then transfer those launch commands to someone else's computer because they are absolute paths. Even though my project can handle relative paths, live-server cannot. This is a very very very basic use case that live-server doesn't support and it should be removed as an NPM package if it can't be used this way.

Maybe an option --relative-root is necessary here so that I can instruct people how to launch my project?

briancullinan2 avatar Sep 03 '24 18:09 briancullinan2