Registry / web-framework / estree-to-babel

estree-to-babel

JSON →
library12.0.1jsnpmunverified

Converts ESTree-compatible JavaScript AST (from parsers like acorn, cherow, espree) to Babel AST for use with tools like @babel/traverse, @babel/types, etc. Current stable version is v12.0.1, released in 2025. Requires Node >=22 and ships TypeScript types. Key differentiators: handles differences between ESTree and Babel AST (Literal vs StringLiteral, ChainExpression vs OptionalMemberExpression, etc.), TypeScript-ESTree specifics (ClassPrivateProperty, TSQualifiedName), and provides convertParens option to control parenthesization. ESM-only since v12, dropping CommonJS support.

npm install estree-to-babel
INSTALL
IMPORT
SIG · ESTREE-TO-BABEL
E
estree-to-babel
web-frameworkjavascriptv12.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

estreeToBabel
import { estreeToBabel } from 'estree-to-babel'
const estreeToBabel = require('estree-to-babel')
ESM-only since v12.0.0; CommonJS require will fail.
estreeToBabel default export
import convert from 'estree-to-babel'
import { convert } from 'estree-to-babel'
The default export is also the estreeToBabel function. Avoid named import 'convert'.
for TypeScript types
import type { EstreeToBabelOptions } from 'estree-to-babel'
import { EstreeToBabelOptions } from 'estree-to-babel'
Type import to avoid bundling. Options type is exported since v11.0.2.

Parses JavaScript with cherow, converts to Babel AST, and traverses using @babel/traverse.

import { parse } from 'cherow'; import { estreeToBabel } from 'estree-to-babel'; import { traverse } from '@babel/traverse'; const source = ` const f = ({a}) => a; `; const estreeAst = parse(source); const babelAst = estreeToBabel(estreeAst); traverse(babelAst, { ObjectProperty(path) { console.log(path.node.key.name); // output: 'a' }, });
Debug
Known issues
breakingv12.0.0 dropped CommonJS support; package is ESM-only. require() will throw ERR_REQUIRE_ESM.
fix
Use import statements instead of require(). If you need CommonJS, stay on v11.x.
affects: >=12.0.0
breakingv12.0.0 dropped support for Node < 22. Older Node versions will produce runtime errors.
fix
Upgrade Node.js to >=22.0.0.
affects: >=12.0.0
gotchaThe function mutates the input AST object; it does not return a new copy. Be careful if you need to keep the original ESTree AST.
fix
Clone the input AST before passing to estreeToBabel if you need the original.
affects: *
deprecatedconvertParens option default will change in future versions; currently defaults to true (parenthesized expressions are converted).
fix
Explicitly set convertParens: true/false to future-proof your code.
affects: >=10.5.0 <13.0.0
Errors
Common errors & fixes
SyntaxError: Cannot use import statement outside a module
Using ESM import syntax with CommonJS project (no 'type': 'module' in package.json).
fix
Add 'type': 'module' to package.json or use .mjs extension.
TypeError: estreeToBabel is not a function
Using require('estree-to-babel') which returns a module object, not the function directly. For CommonJS, use require('estree-to-babel').default or stay on v11.
fix
Use import { estreeToBabel } from 'estree-to-babel' (ESM) or require('estree-to-babel').default (CJS, but not recommended).
Module not found: Can't resolve 'estree-to-babel'
Missing npm install or incorrect path.
fix
Run 'npm install estree-to-babel' and ensure node_modules is present.
Upgrade
Version history
12.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources
estree-to-babel — npm install estree-to-babel · libregistry