Registry / devops / esbuild-serve

esbuild-serve

JSON →
library1.0.1jsnpmunverified

A lightweight wrapper around esbuild that adds a static file server with live reload functionality. Version 1.0.1 is the latest stable release. It is ideal for development workflows where you want esbuild's fast build times combined with automatic browser refreshes on file changes. Unlike heavier alternatives like webpack-dev-server, esbuild-serve has a minimal dependency footprint and focuses solely on serving static files with live reload via esbuild's watch mode. It wraps the ultralight 'serve' HTTP server and requires no complex configuration.

npm install esbuild-serve
INSTALL
IMPORT
SIG · ESBUILD-SERVE
E
esbuild-serve
devopsjavascriptv1.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

esbuildServe
import esbuildServe from 'esbuild-serve';
const esbuildServe = require('esbuild-serve');
ESM-only package; CommonJS require() will fail.
default import
import esbuildServe from 'esbuild-serve';
import { esbuildServe } from 'esbuild-serve';
The package exports a single default function. Named import syntax will result in undefined.
TypeScript usage
import esbuildServe from 'esbuild-serve';
import esbuildServe = require('esbuild-serve');
If using TypeScript, ensure 'esModuleInterop' is true in tsconfig.json for default imports.

Demonstrates starting an esbuild build with watch mode and a static server with live reload on port 8000.

import esbuildServe from 'esbuild-serve'; const buildOptions = { entryPoints: ['src/index.js'], outfile: 'dist/bundle.js', bundle: true, watch: { onRebuild(error) { if (error) console.error('Build failed:', error); } } }; const serveOptions = { port: 8000, root: 'public' }; esbuildServe(buildOptions, serveOptions) .then(() => console.log('Server started at http://localhost:8000')) .catch(err => console.error(err));
esbuild-serve --version
Debug
Known issues
gotchaesbuild-serve relies on esbuild's watch mode, which will rebundle on file changes but may not trigger livereload if the output file does not change (e.g., errors during rebuild).
fix
Ensure your esbuild configuration outputs a file that changes on every successful rebuild. Consider using a placeholder comment.
affects: >=1.0.0
breakingThe serve options object is optional; if omitted, default serve options are used. However, if you pass an empty object, it may override defaults unexpectedly.
fix
Either omit the serve options argument entirely or provide all desired options explicitly.
affects: >=1.0.0
deprecatedThe package currently uses the 'serve' library by the same author. Future versions might replace it with a different server; stay updated.
fix
Monitor the package's GitHub releases for migration notes.
affects: >=1.0.0
Errors
Common errors & fixes
Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'esbuild-serve'
Missing or incorrect dependency installation; possibly missing from package.json or not in node_modules.
fix
Run 'npm install esbuild-serve --save-dev' (or --save) to install the package.
TypeError: esbuildServe is not a function
Using named import syntax (import { esbuildServe } from 'esbuild-serve') instead of default import.
fix
Change to default import: import esbuildServe from 'esbuild-serve'
Error [ERR_REQUIRE_ESM]: require() of ES Module not supported
Trying to use require() to load an ESM-only package.
fix
Use import syntax instead of require. Ensure your project is configured for ESM (e.g., type: 'module' in package.json).
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies
serverequiredProvides the HTTP server and live reload capability
Agent activity
2 hits · last 30 days
node
2
Resources
esbuild-serve — npm install esbuild-serve · libregistry