Static Cling
raw JSON → 2.0.3 verified Mon Apr 27 auth: no javascript maintenance
A minimal static file server for Node.js, version 2.0.3, providing both a command-line interface and programmatic usage. It serves files from a directory with optional custom port, root path, and default filename. Last updated in 2019, it has low maintenance cadence. Differentiators: extremely simple setup with no dependencies (pure Node.js http module), suitable for quick local development or demonstrations. Alternatives like http-server or serve offer more features and active maintenance.
Common errors
error Error: Cannot find module 'static-cling' ↓
cause Package not installed or not in node_modules.
fix
npm install static-cling --save
error static: command not found ↓
cause Package not installed globally or PATH issue.
fix
npm install -g static-cling
Warnings
gotcha CLI command is just 'static', which may conflict with other tools. Ensure global install and no name collision. ↓
fix Use --global flag during npm install; check for conflicting binaries with 'which static'.
deprecated Package last updated in 2019; no maintenance or security patches. ↓
fix Consider alternatives like 'http-server' or 'serve' for active support.
gotcha Does not support HTTPS, caching, or directory listing by default. ↓
fix Use reverse proxy (e.g., nginx) or switch to a feature-rich server.
Install
npm install static-cling yarn add static-cling pnpm add static-cling Imports
- default wrong
import cling from 'static-cling';correctconst cling = require('static-cling'); cling(); - default with options wrong
require('static-cling').serve({ port: 8080 });correctrequire('static-cling')({ port: 8080, root: './public' }); - CLI usage wrong
npx staticcorrectstatic -p 4000 -d ./dist
Quickstart
const cling = require('static-cling');
cling({ port: process.env.PORT || 3000, root: './public', filename: 'index.html' });