{"id":25550,"library":"esrun","title":"esrun","description":"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.","status":"deprecated","version":"3.2.30","language":"javascript","source_language":"en","source_url":"https://github.com/digital-loukoum/esrun","tags":["javascript","esbuild","run","execute","typescript"],"install":[{"cmd":"npm install esrun","lang":"bash","label":"npm"},{"cmd":"yarn add esrun","lang":"bash","label":"yarn"},{"cmd":"pnpm add esrun","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used to compile TypeScript to JavaScript at runtime.","package":"esbuild","optional":false}],"imports":[{"note":"The package is ESM-only from v3; CommonJS require will throw.","wrong":"const esrun = require('esrun')","symbol":"default","correct":"import esrun from 'esrun'"},{"note":"Named export 'run' available only via ESM import.","wrong":"const { run } = require('esrun')","symbol":"run","correct":"import { run } from 'esrun'"},{"note":"Types are exported, but using them as values will cause runtime errors.","wrong":"import { Options } from 'esrun' (value import)","symbol":"types (TypeScript)","correct":"import type { Options } from 'esrun'"}],"quickstart":{"code":"// 1. Install globally or locally\n// npm i -g esrun\n\n// 2. Create a TypeScript file: hello.ts\n// content:\nimport { run } from 'esrun';\nimport { greet } from './greet';\n\nasync function main() {\n  const message = await greet('World');\n  console.log(message);\n}\n\n// greet.ts \nexport async function greet(name: string): Promise<string> {\n  return `Hello, ${name}!`;\n}\n\n// 3. Execute: esrun hello.ts","lang":"typescript","description":"Shows a minimal TypeScript file with an async import, executed via esrun CLI."},"warnings":[{"fix":"Migrate to Bun (bun run file.ts) or tsx (npx tsx file.ts).","message":"This package is deprecated. Use Bun or tsx instead.","severity":"deprecated","affected_versions":">=3.0.0"},{"fix":"Use ESM imports (import) or use an older v2.x if absolutely required.","message":"v3 dropped CommonJS support. require() will throw.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Correct: esrun --watch foo.ts. Wrong: esrun foo.ts --watch.","message":"Watch mode flag --watch must be placed before the file path, otherwise it's passed as an argument to the script.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Set \"compilerOptions\": { \"module\": \"esnext\" } in tsconfig.json.","message":"Top-level await requires module setting in tsconfig: \"module\": \"esnext\".","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Pass tsconfig via esrun --tsconfig=/path (still supported, but not guaranteed).","message":"Use of --tsconfig parameter may be removed in future versions.","severity":"deprecated","affected_versions":">=3.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Change to dynamic import: const esrun = await import('esrun'); or switch to ESM.","cause":"Using CommonJS require() with ESM-only esrun v3.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/esrun not supported."},{"fix":"Use consistent ESM syntax: export/import, not module.exports/require.","cause":"Mixing import/export with CommonJS module.exports in the executed file.","error":"ReferenceError: exports is not defined in ES module scope"},{"fix":"Use absolute path or relative path from current working directory.","cause":"Invalid path provided to --tsconfig parameter.","error":"Could not resolve: /path/to/tsconfig.json (tsconfig not found)"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}