Registry / devops / esbin
library0.0.4jsnpmunverified

A fork of esbuild-register providing a hook for Node.js to transpile TypeScript, JSX, and modern JS on-the-fly using esbuild. Current version 0.0.4 requires esbuild >=0.19 <1. It aims to be a minimal drop-in replacement for ts-node with faster transpilation due to esbuild's speed. Unlike ts-node or sucrase, esbin is a thin wrapper around esbuild's transform API, offering no type checking. It is designed for development workflows where fast module loading is critical. The package is in early maintenance mode, with no breaking changes expected. Key differentiators: zero configuration, ESM and CJS support, and simple integration.

npm install esbin
INSTALL
IMPORT
SIG · ESBIN
E
esbin
devopsjavascriptv0.0.4
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 esbin)
import 'esbin/register'
import esbin from 'esbin'
esbin is not a default export; you must import the side-effect module 'esbin/register' to register the hooks.
register
import { register } from 'esbin'
const { register } = require('esbin')
register is a named export. The package is ESM-only; CommonJS require is not supported and will cause a SyntaxError.
node -r esbin/register
node -r esbin/register script.ts
node -r esbin script.ts
To use the require hook, you must specify the full path 'esbin/register' or 'esbin/register' (with comma). Simply requiring 'esbin' does not register the hook.

Demonstrates how to programmatically register esbin with custom esbuild options and import TypeScript files, or use the CLI require hook.

import { register } from 'esbin'; import esbuild from 'esbuild'; register({ // optional: custom esbuild options target: 'node18', tsconfigRaw: '{}', }); // now you can import TypeScript files import './my-module.ts'; // Or use the CLI node -r esbin/register // Then run: node -r esbin/register script.ts
Debug
Known issues
gotchaesbin does **not** perform type checking; it only transpiles. Type errors will not be caught at runtime.
fix
Run a separate type check (e.g., tsc --noEmit) or use ts-node with type checking if needed.
affects: >=0.0.1
breakingPackage is ESM-only. Using require('esbin') or require('esbin/register') will throw a SyntaxError.
fix
Use import statements or use a dynamic import (e.g., await import('esbin/register')).
affects: >=0.0.1
gotchaThe register function must be called before importing any TypeScript files. Calling it after imports may not work.
fix
Call register() at the very top of your entry point, or use the command line -r flag.
affects: >=0.0.1
deprecatedesbin is a fork of the deprecated esbuild-register package. The original may have breaking changes or lack of updates.
fix
Consider using the original esbuild-register (though it's deprecated) or evaluate alternative solutions like tsx or ts-node.
affects: >=0.0.1
gotchaWhen using Node.js's --experimental-loader, esbin may conflict with other loaders. Not all module systems (e.g., REPL) are supported.
fix
Use only one require hook or loader at a time. For REPL, load esbin/register via -r.
affects: >=0.0.1
Errors
Common errors & fixes
SyntaxError: Unexpected token 'export'
Using CommonJS require() to import an ESM-only package.
fix
Change to import statement or use dynamic import: await import('esbin/register').
TypeError: esbin_register is not a function
Importing default export from 'esbin' when only named export 'register' exists.
fix
Use import { register } from 'esbin' instead of import register from 'esbin'.
Error: Cannot find module 'esbin/register'
Running node -r esbin without the full path 'esbin/register'.
fix
Use node -r esbin/register script.ts (note the trailing slash and register).
Upgrade
Version history
0.0.4latest on npm
Audit
Dependencies
esbuildrequiredpeer dependency: uses esbuild's transform API for transpilation
Agent activity
8 hits · last 30 days
node
6
Resources
packageesbin
esbin — npm install esbin · libregistry