{"id":25447,"library":"esbuild-serve","title":"esbuild-serve","description":"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.","status":"active","version":"1.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/nativew/esbuild-serve","tags":["javascript","esbuild","wrapper","plugin","serve","http","server","livereload","live"],"install":[{"cmd":"npm install esbuild-serve","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-serve","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-serve","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Provides the HTTP server and live reload capability","package":"serve","optional":false}],"imports":[{"note":"ESM-only package; CommonJS require() will fail.","wrong":"const esbuildServe = require('esbuild-serve');","symbol":"esbuildServe","correct":"import esbuildServe from 'esbuild-serve';"},{"note":"The package exports a single default function. Named import syntax will result in undefined.","wrong":"import { esbuildServe } from 'esbuild-serve';","symbol":"default import","correct":"import esbuildServe from 'esbuild-serve';"},{"note":"If using TypeScript, ensure 'esModuleInterop' is true in tsconfig.json for default imports.","wrong":"import esbuildServe = require('esbuild-serve');","symbol":"TypeScript usage","correct":"import esbuildServe from 'esbuild-serve';"}],"quickstart":{"code":"import esbuildServe from 'esbuild-serve';\n\nconst buildOptions = {\n  entryPoints: ['src/index.js'],\n  outfile: 'dist/bundle.js',\n  bundle: true,\n  watch: {\n    onRebuild(error) {\n      if (error) console.error('Build failed:', error);\n    }\n  }\n};\n\nconst serveOptions = {\n  port: 8000,\n  root: 'public'\n};\n\nesbuildServe(buildOptions, serveOptions)\n  .then(() => console.log('Server started at http://localhost:8000'))\n  .catch(err => console.error(err));","lang":"typescript","description":"Demonstrates starting an esbuild build with watch mode and a static server with live reload on port 8000."},"warnings":[{"fix":"Ensure your esbuild configuration outputs a file that changes on every successful rebuild. Consider using a placeholder comment.","message":"esbuild-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).","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Either omit the serve options argument entirely or provide all desired options explicitly.","message":"The serve options object is optional; if omitted, default serve options are used. However, if you pass an empty object, it may override defaults unexpectedly.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Monitor the package's GitHub releases for migration notes.","message":"The package currently uses the 'serve' library by the same author. Future versions might replace it with a different server; stay updated.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run 'npm install esbuild-serve --save-dev' (or --save) to install the package.","cause":"Missing or incorrect dependency installation; possibly missing from package.json or not in node_modules.","error":"Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'esbuild-serve'"},{"fix":"Change to default import: import esbuildServe from 'esbuild-serve'","cause":"Using named import syntax (import { esbuildServe } from 'esbuild-serve') instead of default import.","error":"TypeError: esbuildServe is not a function"},{"fix":"Use import syntax instead of require. Ensure your project is configured for ESM (e.g., type: 'module' in package.json).","cause":"Trying to use require() to load an ESM-only package.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module not supported"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}