TS-Directly (v2.1.2) is a lightweight ESM loader that lets Node.js execute TypeScript files directly using the compiler already installed in the project (SWC, esbuild, sucrase, or tsc). It features automatic compiler detection (preferring the fastest), respects closest tsconfig.json including baseUrl/paths aliases, supports .cts/.mts files and ESNext module output, and exposes a transform API. Unlike ts-node or tsx it does not bundle a compiler, making it ideal for CLI tools that want to reuse existing dependencies. Released monthly on npm, actively maintained with 5 KB minified size and zero extra dependency beyond node loaders.
npm install ts-directlyNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to import and use the transform API, and how to register the loader to run TS files directly.
Use the automatic detection or switch to transform() which internally detects the compiler.
Use import statements or dynamic import() instead of require().
Install one of: @swc/core, esbuild, sucrase, or typescript. If multiple are present, the fastest (esbuild > sucrase > swc > tsc) is chosen.
Always use full file paths with extensions for aliased imports, or avoid alias for directory resolution.
Use the loader registration if you need import resolution (e.g., .js -> .ts redirection), not just transform().
Install one of: @swc/core, esbuild, sucrase, or typescript as a dependency.
Use import statements or dynamic import(). If you must use CommonJS, downgrade to v1.x.
Set TS_COMPILER to one of: 'swc', 'esbuild', 'sucrase', 'tsc' (case-insensitive).