{"id":12012,"library":"servez","title":"Simple Command-Line HTTP Server","description":"Servez is a straightforward command-line HTTP server designed for local development and learning, serving static files quickly. As of version 2.4.0, it offers zero-configuration defaults but provides a rich set of options for customization, including port selection, directory listing, CORS headers, gzip/brotli compression, and basic authentication. Its primary differentiator is its simplicity and ease of use, aiming to replace tools like `http-server` with a modern, actively maintained alternative. It supports both HTTP and HTTPS (with self-signed or custom certificates) and can display QR codes for easy mobile access. The project appears to have a regular, albeit not fixed, release cadence, driven by user needs and feature enhancements, making it a reliable choice for development server needs.","status":"active","version":"2.4.0","language":"javascript","source_language":"en","source_url":"https://github.com/greggman/servez-cli","tags":["javascript","http","https","server","cli","command"],"install":[{"cmd":"npm install servez","lang":"bash","label":"npm"},{"cmd":"yarn add servez","lang":"bash","label":"yarn"},{"cmd":"pnpm add servez","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This refers to executing the 'servez' command after a global npm installation. It is primarily a CLI tool and not designed for direct programmatic import as a JavaScript module.","wrong":"import servez from 'servez';","symbol":"servez","correct":"servez [options] [path]"},{"note":"Using 'npx' allows you to execute 'servez' on-demand without a global installation, ensuring you use the latest version or a specific version by appending '@<version>'.","symbol":"npx servez","correct":"npx servez [options] [path]"},{"note":"This command installs the 'servez' executable globally on your system, making it accessible from any directory in your terminal.","wrong":"require('servez').installGlobal();","symbol":"npm install -g servez","correct":"npm install -g servez"}],"quickstart":{"code":"const { spawn } = require('child_process');\nconst path = require('path');\nconst fs = require('fs');\n\nconst publicDir = path.join(__dirname, 'public');\nif (!fs.existsSync(publicDir)) {\n  fs.mkdirSync(publicDir);\n}\nfs.writeFileSync(path.join(publicDir, 'index.html'), '<h1>Hello, Servez from JS!</h1>');\nfs.writeFileSync(path.join(publicDir, 'style.css'), 'body { font-family: sans-serif; }');\n\nconsole.log('Starting servez...');\nconst servezProcess = spawn('npx', ['servez', publicDir, '--port', '8080', '--dirs', '--cors', '--qr', '--local', '--index'], {\n  stdio: 'inherit',\n  shell: true // Needed on Windows for npx to be found\n});\n\nservezProcess.on('error', (err) => {\n  console.error('Failed to start servez process:', err);\n});\n\nservezProcess.on('exit', (code) => {\n  console.log(`servez process exited with code ${code}`);\n});\n\nconsole.log('Server should be available at http://localhost:8080');\nconsole.log('Press Ctrl+C to stop this script and the servez server.');\n","lang":"javascript","description":"Demonstrates how to programmatically start `servez` from a Node.js script, creating a public directory with sample content and serving it on port 8080 with directory listings, CORS, QR code, and local access enabled."},"warnings":[{"fix":"Always include `--local` if you intend for the server to be accessible only from `127.0.0.1` (localhost).","message":"By default, `servez` serves on all network interfaces (0.0.0.0), making it publicly accessible on your local network. To restrict access only to the local machine, use the `--local` option.","severity":"gotcha","affected_versions":">=2.0"},{"fix":"For secure development, either configure your browser to trust the self-signed certificate, or provide valid, trusted certificates using `--cert` and `--key`.","message":"When using `--ssl` without specifying `--cert` and `--key` paths, `servez` generates a self-signed (fake) SSL certificate. Browsers will typically warn about this as the certificate is not trusted by a recognized Certificate Authority.","severity":"gotcha","affected_versions":">=2.0"},{"fix":"Check the server output in the terminal to confirm the exact port being used, or explicitly specify a port with `--port <number>`.","message":"If the default port 8080 is already in use, `servez` will automatically scan for and use the next available port. Users might inadvertently connect to a different port than expected.","severity":"gotcha","affected_versions":">=2.0"},{"fix":"Install Node.js via `nvm` (mac/linux) or `nvm-windows` (windows) before attempting to install or run `servez`.","message":"The `servez` CLI tool requires Node.js to be installed on your system. Using a Node Version Manager (like nvm or nvm-windows) is highly recommended to manage Node.js versions effectively.","severity":"gotcha","affected_versions":">=2.0"}],"env_vars":null,"search_vec":"'2.4.0':29 'access':102 'activ':78 'aim':67 'albeit':110 'altern':80 'appear':105 'authent':56 'basic':55 'cadenc':114 'certif':93 'choic':126 'cli':135 'code':98 'command':3,12,136 'command-lin':2,11 'compress':53 'configur':34 'cor':50 'custom':44,92 'default':35 'design':16 'develop':19,128 'differenti':59 'directori':48 'display':96 'driven':115 'eas':64 'easi':100 'enhanc':121 'featur':120 'file':24 'fix':112 'gzip/brotli':52 'header':51 'http':5,14,73,84,132 'http-server':72 'https':86,133 'includ':45 'javascript':131 'learn':21 'like':71 'line':4,13 'list':49 'local':18 'maintain':79 'make':122 'mobil':101 'modern':77 'need':118,130 'offer':31 'option':42 'port':46 'primari':58 'project':104 'provid':37 'qr':97 'quick':25 'regular':109 'releas':113 'reliabl':125 'replac':69 'rich':39 'select':47 'self':89 'self-sign':88 'serv':22 'server':6,15,74,129,134 'servez':7 'set':40 'sign':90 'simpl':1 'simplic':62 'static':23 'straightforward':10 'support':82 'tool':70 'use':66 'user':117 'version':28 'zero':33 'zero-configur':32","created_at":"2026-04-19T13:40:58.284521+00:00","updated_at":"2026-04-19T13:40:58.284521+00:00","problems":[{"fix":"Install it globally via `npm install -g servez` or execute it directly using `npx servez`.","cause":"The `servez` command is not available in your system's PATH.","error":"servez: command not found"},{"fix":"Ensure `servez` is running and check the console output for the correct URL (e.g., `http://localhost:8080` or the next available port). If using `--local`, confirm you're accessing `127.0.0.1`.","cause":"The `servez` server is not running, or it's running on a different port/address than you're trying to access.","error":"ERR_CONNECTION_REFUSED"},{"fix":"Start `servez` with the `--cors` option to enable CORS headers: `servez --cors`.","cause":"Your browser is blocking a cross-origin request because the `servez` server did not send the necessary CORS headers.","error":"Access to fetch at 'http://localhost:8080/data.json' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource."},{"fix":"For development, you can usually proceed past the browser warning. For a trusted setup, provide your own valid SSL certificate and key files using `--cert <path_to_cert>` and `--key <path_to_key>`.","cause":"You are using HTTPS (`--ssl`) with a self-signed certificate that your browser does not implicitly trust.","error":"NET::ERR_CERT_AUTHORITY_INVALID"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"servez","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/greggman/servez-cli","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/servez","openapi_spec":null,"status_page":null,"smithery":null,"categories":["http-networking","web-framework","devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}