CLI quick start

Serve a folder locally.

Install the command globally, or use npx. The default listener is reachable only from this machine.

shell
npm install --global node-http-server
node-http-server --root ./public
Expected output
node-http-server listening at http://127.0.0.1:8080
No global install: run npx node-http-server --root ./public. See the CLI task guide for flags, failures, exit behavior, and deployment examples.

Library quick start

Create an isolated server.

CommonJS
const {Server}=require('node-http-server');

new Server({root:'./public'}).deploy();
ESM
import {Server} from 'node-http-server';

new Server({root:'./public'}).deploy();

The original default singleton remains available in both module systems. New applications should normally create a named Server instance so listener and configuration state stay isolated.

Starting behavior

Know the defaults before changing them.

127.0.0.1Listen address
8080HTTP port
index.htmlDirectory index
current directoryStatic root
BehaviorDefaultChange it
Request-body limitUnlimitedserver.maxRequestBodyBytes
CompressionOffserver.compression
SPA fallbackOffserver.spaFallback
DotfilesBlocked with 403server.allowDotfiles
Automatic MIME typesBuilt-in mapcontentType
Request loggingOfflog
HTTPSOffhttps
Network exposure: set host:'0.0.0.0' or --host 0.0.0.0 only when other machines should connect. Read Operations and security first.

Documentation by task

Go directly to the job.

Project status

Published facts and measured coverage.