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
muslnode 18–226 runs
build_error
glibcnode 18–226 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.fixUse 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.fixUpgrade 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.fixClone 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).fixExplicitly 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).
fixAdd '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.
fixUse 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.
fixRun 'npm install estree-to-babel' and ensure node_modules is present.
Audit
Dependencies
No dependency data recorded yet.