sirv-cli
raw JSON → 3.0.1 verified Sat Apr 25 auth: no javascript
sirv-cli is a lightweight, zero-config CLI tool for serving static files from any directory. It supports HTTP/2, CORS, ETags, gzip/brotli precompressed files, single-page app fallback, and immutable cache headers. Version 3.0.1 requires Node 18+ and ships native ESM via an exports map. It differs from alternatives like http-server or serve by being minimal, fast, and designed for development previews. Regular releases (2-3 per year) with breaking changes infrequent.
Common errors
error Error: listen EADDRINUSE :::8080 ↓
cause Port 8080 already in use by another process
fix
Use a different port with --port or kill the process using the current port.
error Error: Cannot find module 'sirv-cli' ↓
cause sirv-cli not installed
fix
Run 'npm install -g sirv-cli' or 'npx sirv-cli'.
error sirv: command not found ↓
cause sirv-cli not installed globally or not in PATH
fix
Install globally with 'npm install -g sirv-cli' or use npx.
Warnings
breaking Node 18+ required since v3.0.0 ↓
fix Upgrade Node.js to version 18 or later.
breaking Default port changed from 5000 to 8080 in v2.0.0 due to macOS Monterey reserving port 5000 for AirPlay ↓
fix Update scripts or explicitly use --port 5000 if needed.
deprecated HTTP/2 support requires Node 8.4+ but v3 requires Node 18+; --http2 flag still accepted but may be removed in future ↓
fix Use HTTPS with a reverse proxy for HTTP/2 in production.
gotcha HOST and PORT environment variables override --host and --port flags ↓
fix Unset environment variables or use flags exclusively.
gotcha By default server is only accessible on localhost (not network); use --host to expose ↓
fix Add --host flag to allow network access.
Install
npm install sirv-cli yarn add sirv-cli pnpm add sirv-cli Imports
- sirv-cli (CLI) wrong
Running the package directly as a script without npx and missing optionscorrectnpx sirv-cli [dir]
Quickstart
npm install -g sirv-cli
sirv --port 8080 --dev
# Navigate to http://localhost:8080