{"id":10898,"library":"five-server","title":"Five Server","description":"Five Server is a modern development server with live reload capabilities, designed as a maintained fork of the popular `live-server` package. It is completely rewritten in TypeScript and aims to provide up-to-date dependencies and enhanced features compared to its predecessor. Currently at version 0.4.5, it offers features like remote logs for debugging on mobile devices, built-in PHP server support, and compatibility with Server Side Rendered applications (e.g., Express.js). While it ships with a CLI, it also offers a programmatic API for integration into projects. Key differentiators include its robust module import options for various JavaScript environments and features specifically for its VSCode extension, and it targets Node.js version 16 or higher.","status":"active","version":"0.4.5","language":"javascript","source_language":"en","source_url":"https://github.com/yandeu/five-server","tags":["javascript","browser","development","tool","http","html","php","live","server","typescript"],"install":[{"cmd":"npm install five-server","lang":"bash","label":"npm"},{"cmd":"yarn add five-server","lang":"bash","label":"yarn"},{"cmd":"pnpm add five-server","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default ESM import for TypeScript projects or modern browser environments.","wrong":"const FiveServer = require('five-server')","symbol":"FiveServer","correct":"import FiveServer from 'five-server'"},{"note":"Explicit ESM import path for Node.js module environments to ensure correct resolution without relying on package.json 'exports'.","wrong":"import FiveServer from 'five-server'","symbol":"FiveServer","correct":"import FiveServer from 'five-server/esm.mjs'"},{"note":"CommonJS import requires `.default` due to ESM interoperability and how the package is bundled.","wrong":"const FiveServer = require('five-server')","symbol":"FiveServer","correct":"const FiveServer = require('five-server').default"}],"quickstart":{"code":"import FiveServer from 'five-server';\nimport path from 'path';\nimport fs from 'fs';\n\n// Create a dummy 'public' directory and an index.html file for demonstration\nconst publicDir = path.join(process.cwd(), 'public');\nif (!fs.existsSync(publicDir)) {\n  fs.mkdirSync(publicDir, { recursive: true });\n}\nfs.writeFileSync(path.join(publicDir, 'index.html'), '<h1>Hello Five Server!</h1><p>Watch me reload.</p>', 'utf8');\n\n// Example: Serve the 'public' directory on port 8080 without opening a browser automatically.\nconst server = new FiveServer();\nserver.start({\n  port: 8080,\n  root: publicDir, // Set the document root to the 'public' directory\n  open: false, // Do not open browser automatically\n  watch: true, // Enable live reload\n  dir: publicDir // Ensure 'dir' is also set for correct root behavior\n}).then(() => {\n  console.log('Five Server started on http://localhost:8080');\n  console.log(`Watching for changes in: ${publicDir}`);\n  console.log('Open your browser to http://localhost:8080');\n}).catch(err => {\n  console.error('Failed to start Five Server:', err);\n});","lang":"typescript","description":"Demonstrates how to programmatically start Five Server, serving a specific directory on a custom port with live reload, without automatically opening a browser. Includes setup for a test 'public' folder."},"warnings":[{"fix":"Uninstall `live-server` globally and install `five-server`. Review the new API for programmatic usage and configuration options.","message":"Five Server is a complete rewrite and maintained fork of `live-server`. Migrating from `live-server` requires uninstalling the old package (`npm -g rm live-server`) and installing `five-server`. The API for programmatic usage has changed significantly.","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Install the Five Server VSCode Extension (`yandeu.five-server`) to utilize these editor-integrated functionalities.","message":"Advanced features like 'Instant Updates', 'Highlights', and 'Auto Navigation' are exclusively available through the Five Server VSCode Extension, not via the standalone CLI or programmatic API.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Upgrade your Node.js environment to version 16 or newer using a version manager like `nvm` or `fnm`.","message":"Five Server requires Node.js version 16 or higher. Older Node.js versions are not supported, and attempting to run it on unsupported versions will result in errors.","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"For Node.js ESM, use `import FiveServer from 'five-server/esm.mjs'`. For CommonJS, use `const FiveServer = require('five-server').default`.","message":"Due to varied module resolver behaviors across JavaScript environments, explicit import paths or `.default` access might be required for programmatic usage in Node.js ESM or CommonJS. Simply importing from 'five-server' might not always work directly.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Correct the import to `const FiveServer = require('five-server').default;`","cause":"Attempting to instantiate `FiveServer` in CommonJS by directly requiring the package without accessing its default export (e.g., `require('five-server')`).","error":"TypeError: FiveServer is not a constructor"},{"fix":"Use the explicit ESM path: `import FiveServer from 'five-server/esm.mjs';` or fall back to: `import pkg from 'five-server'; const { default: FiveServer } = pkg;`","cause":"Incorrectly using a named import for a default export, or attempting `import FiveServer from 'five-server'` in a Node.js ESM environment where the direct root import might not resolve correctly.","error":"SyntaxError: Named export 'FiveServer' not found. The requested module 'five-server' does not provide an export named 'FiveServer'"},{"fix":"Change the port number in your configuration (e.g., `five-server --port 8081` in CLI, or `{ port: 8081 }` in your programmatic options) or identify and terminate the conflicting process.","cause":"Another process on your system is already using the port that Five Server is trying to bind to (e.g., port 8080).","error":"Error: listen EADDRINUSE: address already in use :::8080"}],"ecosystem":"npm"}