Registry / devops / esrun
library3.2.30jsnpmunverified

esrun is a lightweight CLI tool that executes TypeScript and modern JavaScript files directly using esbuild for near-instant compilation, without requiring a bundler. It supports custom tsconfig, top-level await, and watch mode for re-executing on file changes. It handles both CJS and ESM dependencies seamlessly. However, the package is deprecated as of version 3.2.30 (current stable). Maintainers recommend migrating to Bun or, for Node.js compatibility, tsx. Last useful release: 3.2.30, minimal maintenance since. Designed for quick demonstrations and test execution, it differentiates itself by zero-config setup and esbuild's speed, but is now superseded.

npm install esrun
INSTALL
IMPORT
SIG · ESRUN
E
esrun
devopsjavascriptv3.2.30
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.

default
import esrun from 'esrun'
const esrun = require('esrun')
The package is ESM-only from v3; CommonJS require will throw.
run
import { run } from 'esrun'
const { run } = require('esrun')
Named export 'run' available only via ESM import.
types (TypeScript)
import type { Options } from 'esrun'
import { Options } from 'esrun' (value import)
Types are exported, but using them as values will cause runtime errors.

Shows a minimal TypeScript file with an async import, executed via esrun CLI.

// 1. Install globally or locally // npm i -g esrun // 2. Create a TypeScript file: hello.ts // content: import { run } from 'esrun'; import { greet } from './greet'; async function main() { const message = await greet('World'); console.log(message); } // greet.ts export async function greet(name: string): Promise<string> { return `Hello, ${name}!`; } // 3. Execute: esrun hello.ts
esrun --version
Debug
Known issues
deprecatedThis package is deprecated. Use Bun or tsx instead.
fix
Migrate to Bun (bun run file.ts) or tsx (npx tsx file.ts).
affects: >=3.0.0
breakingv3 dropped CommonJS support. require() will throw.
fix
Use ESM imports (import) or use an older v2.x if absolutely required.
affects: >=3.0.0
gotchaWatch mode flag --watch must be placed before the file path, otherwise it's passed as an argument to the script.
fix
Correct: esrun --watch foo.ts. Wrong: esrun foo.ts --watch.
affects: >=1.0.0
gotchaTop-level await requires module setting in tsconfig: "module": "esnext".
fix
Set "compilerOptions": { "module": "esnext" } in tsconfig.json.
affects: >=2.0.0
deprecatedUse of --tsconfig parameter may be removed in future versions.
fix
Pass tsconfig via esrun --tsconfig=/path (still supported, but not guaranteed).
affects: >=3.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/esrun not supported.
Using CommonJS require() with ESM-only esrun v3.
fix
Change to dynamic import: const esrun = await import('esrun'); or switch to ESM.
ReferenceError: exports is not defined in ES module scope
Mixing import/export with CommonJS module.exports in the executed file.
fix
Use consistent ESM syntax: export/import, not module.exports/require.
Could not resolve: /path/to/tsconfig.json (tsconfig not found)
Invalid path provided to --tsconfig parameter.
fix
Use absolute path or relative path from current working directory.
Upgrade
Version history
3.2.30latest on npm
Audit
Dependencies
esbuildrequiredUsed to compile TypeScript to JavaScript at runtime.
Agent activity
6 hits · last 30 days
node
6
Resources
esrun — npm install esrun · libregistry