Skip to content

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

Description

@briancullinan2
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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions