{"id":18492,"library":"light-server","title":"light-server","description":"A lightweight CLI static HTTP server with file-watching, custom command execution and live-reload capabilities. Version 2.9.1 (latest as of 2023) is a stable release with no active development cadence; last published 5 years ago. Key differentiators against alternatives like BrowserSync: minimal dependencies (~100KB vs >50MB), no build tool integration required, CLI-only usage designed for npm scripts, and built-in live reload with CSS injection without browser plugins. Supports HTTP/2, proxy, SPA history API fallback, and negative glob patterns. Best suited for static site development needing simple server + reload.","status":"maintenance","version":"2.9.1","language":"javascript","source_language":"en","source_url":"https://github.com/txchen/light-server","tags":["javascript","http","server","livereload","live-reload","watch","execute","dev"],"install":[{"cmd":"npm install light-server","lang":"bash","label":"npm"},{"cmd":"yarn add light-server","lang":"bash","label":"yarn"},{"cmd":"pnpm add light-server","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"CLI argument parsing","package":"minimist","optional":false},{"reason":"HTTP request logging","package":"morgan","optional":false},{"reason":"Open browser on startup","package":"opn","optional":false},{"reason":"File watching with globs","package":"gaze","optional":false},{"reason":"Static file serving","package":"serve-static","optional":false},{"reason":"HTTP server framework","package":"connect","optional":false},{"reason":"Proxy functionality","package":"http-proxy","optional":false}],"imports":[{"note":"light-server is a CLI tool, not a library. Use it via npx or npm scripts.","wrong":"require('light-server')","symbol":"default (CLI)","correct":"npx light-server -s . -p 4000"}],"quickstart":{"code":"npx light-server -s . -p 4000 -w \"**/*.css # # reloadcss\"","lang":"javascript","description":"Starts a static server on port 4000 serving current directory, watches CSS files and triggers CSS reload without full page refresh."},"warnings":[{"fix":"No fix expected from maintainer; consider switching to a maintained alternative like live-server or http-server with chokidar-cli.","message":"opn package has been deprecated and renamed to open. May cause security audit warnings.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Avoid spaces in watched paths; use Unix-style escaping or change directory structure.","message":"Watch expressions with spaces in file paths will break. The # delimiter is used without escaping.","severity":"gotcha","affected_versions":"ALL"},{"fix":"Serve only static HTML during development, or disable live reload and use manual refresh.","message":"Live reload injection only works on HTML files. Other file types (e.g., PHP, ASP) do not inject the client script.","severity":"gotcha","affected_versions":"ALL"},{"fix":"Set -s to the actual file directory; use --servePrefix only for URL rewriting.","message":"The --servePrefix option changes the URL path but does NOT affect the file system path. Files are still served from the directory specified by -s.","severity":"gotcha","affected_versions":"ALL"},{"fix":"If you need all requests proxied, use a dedicated proxy tool or configure light-server with --proxypath to selectively proxy.","message":"Proxy option (-x) only proxies when the static file is NOT found (404). It does not proxy all requests.","severity":"gotcha","affected_versions":"ALL"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Ensure .lightserverrc is valid JSON with the same keys as CLI options, e.g., {\"serve\": \".\", \"port\": 4000}.","cause":"Config file is not valid JSON or has wrong structure","error":"Error loading .lightserverrc: Invalid config"},{"fix":"Check that the directory in the watch expression exists; use absolute paths if possible.","cause":"Watched directory does not exist or gaze fails to initialize","error":"Watch error: cannot read property 'on' of undefined"},{"fix":"Use a different port with -p, or kill the existing process: lsof -ti:4000 | xargs kill","cause":"Another process is using the specified port","error":"Port 4000 is already in use"},{"fix":"Run via CLI: npx light-server ... or install globally: npm install -g light-server","cause":"Attempting to require light-server as a Node.js module instead of running as CLI","error":"Cannot find module 'light-server'"},{"fix":"Use -p to specify an available port, or stop the process with kill -9 $(lsof -t -i:4000)","cause":"Same as port in use, but more precise error from Node.js","error":"Error: listen EADDRINUSE: address already in use :::4000"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}