LiveReload Server (Node.js - Legacy)
This entry describes the `livereload-server` package at version `0.2.3`, an extremely early and now effectively abandoned implementation of the LiveReload 3 web socket and HTTP server for Node.js. It targets Node.js versions `>= 0.6.0`, which are long past end-of-life and present significant security vulnerabilities and compatibility issues with modern JavaScript ecosystems. While its purpose was to provide real-time browser reloading during development upon file changes, this specific package version is not suitable for contemporary projects. Developers seeking LiveReload functionality in Node.js should instead use the more actively maintained `livereload` npm package (currently v0.10.x), which serves as its spiritual successor under the same LiveReload organization. This library is primarily of historical interest.
Common errors
-
Error: Cannot find module 'livereload-server'
cause The package `livereload-server` is not widely used or actively maintained and might not be correctly installed or resolved by modern npm/Node.js environments, especially if attempting to use the newer `livereload` package as 'livereload-server'.fixEnsure you have installed the correct package: `npm install livereload` for the modern server, or explicitly install this legacy package if absolutely necessary (not recommended). Double-check your `require()` path. -
TypeError: createServer is not a function
cause This error occurs if the `require('livereload-server')` call does not return an object with a `createServer` method, possibly due to a botched installation, an incorrect package being loaded, or fundamental incompatibility with the Node.js runtime.fixVerify that `livereload-server` is installed. If using a modern Node.js version, this package is likely incompatible; consider migrating to the `livereload` npm package which provides a `createServer` function as its primary API. -
events.js:72 throw er; // Unhandled 'error' event ^ Error: listen EADDRINUSE :::35729cause The default LiveReload port (35729) is already in use by another application, which is a common issue with development servers.fixChange the port for the LiveReload server if the option is available (this legacy package may not support it robustly). For the modern `livereload` package, configure `createServer({ port: YOUR_NEW_PORT })`. Alternatively, ensure no other LiveReload or development servers are running.
Warnings
- breaking This `livereload-server` package (v0.2.3) is extremely old and explicitly requires Node.js version '>= 0.6.0'. It is highly incompatible with modern Node.js runtimes (e.g., Node.js 14+), and attempting to install or run it will likely result in numerous errors related to deprecated APIs, missing modules, or syntax incompatible with current V8 engines.
- gotcha This package is effectively abandoned and has not received updates for over a decade. It likely contains unpatched security vulnerabilities, performance inefficiencies, and lacks support for modern web development practices or browser features. Running it in any environment is a security risk.
- gotcha There is a common confusion between `livereload-server` (this package, version 0.2.3) and the more actively maintained `livereload` npm package (version 0.10.x, last published 8 months ago). Although both are related to LiveReload and originate from the same organization, the `livereload` npm package is the current, albeit CoffeeScript-based, Node.js implementation for LiveReload server functionality.
Install
-
npm install livereload-server -
yarn add livereload-server -
pnpm add livereload-server
Imports
- createServer
import { createServer } from 'livereload-server';const livereload = require('livereload-server'); const server = livereload.createServer(); - ServerOptions
// Type definitions are not available for this legacy version. // Refer to documentation for expected object structure.
Quickstart
const livereload = require('livereload-server');
const server = livereload.createServer({
port: 35729, // Default LiveReload port
// No specific options were common for this extremely old version,
// and its internal implementation details are obscure.
// Modern 'livereload' package options (like 'exts', 'delay', 'https') are not applicable here.
});
// In a real scenario, you'd integrate this with a simple HTTP server
// to serve static files and inject the LiveReload client script.
// For Node.js 0.6, this would likely involve Node's built-in http module.
// Example (highly simplified, assumes a server is already serving files):
// This package typically *only* provides the websocket part.
console.log('LiveReload server (legacy 0.2.3) started on port 35729.');
console.log('Ensure your browser extension or client-side script is configured to connect to this port.');
console.log('Note: This package is for historical context; use the `livereload` npm package for modern projects.');