env-runner is a generic environment runner for JavaScript applications, abstracting away the complexities of various runtime environments. It enables developers to run server applications across Node.js worker threads, child processes, Bun, Deno, Cloudflare Workers (via Miniflare), Vercel, Netlify, or even in-process. The package provides essential features like hot-reloading for development, WebSocket proxying, and a bidirectional messaging system between the main process and the runner environment. Currently at version 0.1.7, it is actively developed with rapid minor releases focusing on enhancements and new runner integrations, offering a unified API for deploying serverless functions or local servers across diverse JavaScript ecosystems. Its key differentiator is providing a consistent interface regardless of the underlying runtime.
npm install env-runnerVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates setting up `EnvServer` to run an application entry point with hot-reloading and proxy requests through a standard HTTP server. Remember to create an `app.ts` file with a default `fetch` handler.
Update `RunnerManager` and `EnvServer` usage to use `.on('event', listener)` or `.onEvent(listener)` methods instead of direct assignment to callback properties.Applications must now manually handle process signals (e.g., `SIGINT`) and explicitly call `.close()` on `EnvServer` or `RunnerManager` instances to ensure proper termination.
Ensure you install the necessary peer dependencies explicitly (e.g., `npm install miniflare @netlify/runtime`) when using their respective runners.
Always consult the package's changelog before upgrading minor versions and consider pinning exact versions in production environments to prevent unexpected issues.
Use the new event listener methods: `manager.onReady((runner, address) => { ... });` or `envServer.onReady((runner, address) => { ... });`Install the missing peer dependency: `npm install miniflare` (or `npm install @netlify/runtime`) in your project.
Ensure your application entry file has `export default { fetch(request: Request) { /* ... */ } };` at its root.Always instantiate runner classes using the `new` keyword: `const runner = new NodeProcessEnvRunner({...});`.