{"id":19357,"library":"babel-register-esm","title":"babel-register-esm","description":"An ESM loader for Babel that transpiles files on-the-fly based on Babel configuration, similar to @babel/register but for ES modules. Current version 1.2.5 is stable with moderate release cadence. It supports importing .ts and .tsx files by resolving .js imports to TypeScript files, a unique feature for TypeScript ESM projects. Requires @babel/core as a peer dependency. Actively maintained, with TypeScript type definitions shipped.","status":"active","version":"1.2.5","language":"javascript","source_language":"en","source_url":"https://github.com/giltayar/babel-register-esm","tags":["javascript","nodejs","typescript"],"install":[{"cmd":"npm install babel-register-esm","lang":"bash","label":"npm"},{"cmd":"yarn add babel-register-esm","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-register-esm","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required for Babel transpilation","package":"@babel/core","optional":false}],"imports":[{"note":"Module has no default export; it's a side-effect loader. Import the module for side effects only.","wrong":"import babelRegisterEsm from 'babel-register-esm'","symbol":"default","correct":"import {} from 'babel-register-esm'"}],"quickstart":{"code":"// Install: npm install babel-register-esm @babel/core\n// Create babelrc.json with plugins, e.g.:\n// {\n//   \"plugins\": [\"@babel/plugin-transform-react-jsx\"]\n// }\n\n// a-file-with-jsx.js\nimport React from 'react';\nconsole.log((<button>Hi</button>).type);\n\n// Run with:\n// node --loader babel-register-esm a-file-with-jsx.js\n\n// For Mocha:\n// mocha --loader=babel-register-esm some-test.js","lang":"javascript","description":"Shows how to install, configure, and run a JSX file with on-the-fly transpilation using the ESM loader."},"warnings":[{"fix":"node --loader babel-register-esm your-file.js","message":"Must run Node.js with --loader babel-register-esm flag. Running without it will not transpile.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"npm install @babel/core","message":"Peer dependency @babel/core must be installed separately. If missing, loader will fail.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"import './file.js' instead of './file.ts'","message":"TypeScript imports must use .js extension even when importing .ts files. Using .ts extension will fail.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Ensure babelrc.json includes @babel/plugin-transform-typescript plugin and isTSX option if needed.","cause":"Importing a .ts file with .js extension but the loader fails to resolve it because Babel plugin for TypeScript is not configured.","error":"Error [ERR_MODULE_NOT_FOUND]: Cannot find module"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}