LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

live-server

development server with live reload

TLDR

Start server in current directory
$ live-server
copy
Serve specific directory
$ live-server [public/]
copy
Custom port
$ live-server --port=[8080]
copy
Open specific file
$ live-server --open=[index.html]
copy
Watch specific paths
$ live-server --watch=[src/,public/]
copy
Disable browser open
$ live-server --no-browser
copy
Serve SPA (fallback to index.html)
$ live-server --entry-file=[index.html]
copy
Enable HTTPS and CORS
$ live-server --https=[https-config.js] --cors
copy

SYNOPSIS

live-server [options] [directory]

DESCRIPTION

live-server is a lightweight Node.js-based HTTP server designed for front-end development that automatically reloads the browser whenever files in the served directory change. It works by injecting a small script into HTML pages that opens a WebSocket connection back to the server, which triggers a page refresh when filesystem modifications are detected.The server requires no configuration to get started and will serve the current directory by default, automatically opening your browser to the root page. You can customize the port, host binding, watched directories, and the initial page to open. Because it is intended strictly for development, it should not be used in production environments.

PARAMETERS

DIRECTORY

Directory to serve (defaults to current).
--port=PORT
Server port (default: 8080, or PORT env var).
--host=HOST
Host address to bind (default: 0.0.0.0, or IP env var).
--open=PATH
Path to open in browser on start.
--watch=PATHS
Comma-separated paths to watch for changes.
--ignore=PATHS
Comma-separated paths to exclude from watching.
--no-browser
Don't auto-launch browser.
--browser=BROWSER
Specify which browser to open.
--no-css-inject
Reload full page on CSS changes instead of live-injecting.
--entry-file=PATH
Fallback file for missing requests (useful for SPAs).
--mount=ROUTE:PATH
Map a URL route to a directory.
--proxy=ROUTE:URL
Proxy requests matching route to URL.
--https=PATH
Path to HTTPS configuration module.
--cors
Enable CORS for all requests.
--wait=MS
Delay (ms) before reloading (default: 100).
-q, --quiet
Suppress log output.
-V, --verbose
Verbose logging.
-v, --version
Show version.
-h, --help
Display help information.

CAVEATS

Node.js required. Development use only. Not for production.

HISTORY

live-server was created to simplify front-end development with automatic browser refresh on file changes.

SEE ALSO

Copied to clipboard
Kai