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.
findBabelConfig
✓ import findBabelConfig from 'find-babel-config'
✗ const findBabelConfig = require('find-babel-config')
Default export is the async function. In CommonJS, require works fine; no default import distinction.
findBabelConfigSync
✓ import findBabelConfig from 'find-babel-config'; const sync = findBabelConfig.sync
✗ import { sync } from 'find-babel-config'
The sync method is a property of the default export, not a named export.
Result
✓ import findBabelConfig from 'find-babel-config'; type Result = { file: string | null; config: any }
✗ import { Result } from 'find-babel-config'
TypeScript types are not exported; you must define the result type yourself.
Demonstrates async and sync usage to find the closest babel config from the current directory.
import findBabelConfig from 'find-babel-config';
// Async usage
const directory = process.cwd();
findBabelConfig(directory)
.then(({ file, config }) => {
if (file) {
console.log('Found config at:', file);
console.log('Config:', JSON.stringify(config, null, 2));
} else {
console.log('No babel config found');
}
})
.catch(err => {
console.error('Error finding config:', err);
});
// Sync usage
const { file, config } = findBabelConfig.sync(directory);
if (file) {
console.log('Sync found config at:', file);
}
Errors
Common errors & fixes
Cannot find module 'find-babel-config'
Package not installed or not in node_modules.
fixRun 'npm install find-babel-config' or add to package.json.
findBabelConfig.sync is not a function
CommonJS require returns the async function; sync is not automatically imported.
fixUse 'const findBabelConfig = require('find-babel-config'); const sync = findBabelConfig.sync;' TypeError: findBabelConfig is not a function
Default import from ESM might fail if bundler treats it incorrectly.
fixEnsure bundler supports CommonJS interop. Use 'import pkg from 'find-babel-config'; const findBabelConfig = pkg.default || pkg;'
ENOENT: no such file or directory, scandir '/some/path'
The provided directory does not exist.
fixVerify the directory path exists before calling findBabelConfig.
Audit
Dependencies
json5requiredUsed to parse .babelrc files that may contain JSON5 syntax.
path-existsrequiredChecks if the config file path exists on the filesystem.