Babel's require hook for Node.js that automatically compiles files on the fly when required. Current stable version is 6.26.0 (legacy Babel 6) and 7.x (latest v7.29.2). Babel 8 (v8.0.0-rc.3) is in release candidate phase. This package binds to Node's require() to transpile .es6, .es, .jsx, and .js files. Key differentiator: it's the simplest way to use Babel without a build step, ideal for development or small scripts. Alternatives like @babel/register for Babel 7+ are recommended. Supports caching via BABEL_CACHE_PATH, and ignores node_modules by default. Note: does not include polyfills; requires separate babel-polyfill for generators/async.
npm install babel-registerVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic usage of babel-register to transpile files on the fly with preset-env and caching.
Replace require('babel-register') with require('@babel/register') in Babel 7 projects.Add { ignore: false } or { only: /your_folder/ } to options.Use babel-node instead, or pre-compile those files.
Add require('babel-polyfill') before require('babel-register').Use @babel/register with Babel 8.
Install babel-polyfill and add require('babel-polyfill') before require('babel-register').Run npm install babel-core --save-dev (or babel-core@^7 for Babel 7).
Upgrade all Babel packages to @babel/scoped versions (e.g., @babel/core instead of babel-core).