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.

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
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.
npm install static-cling
yarn add static-cling
pnpm add static-cling

Shows how to start a static file server programmatically with custom port, root, and default file.

const cling = require('static-cling');
cling({ port: process.env.PORT || 3000, root: './public', filename: 'index.html' });