read-babelrc-up
raw JSON → 1.1.0 verified Sat Apr 25 auth: no javascript maintenance
Utility to find and parse the closest Babel configuration file (`.babelrc`, `.babelrc.js`, `babel.config.js`, or `babel` in `package.json`) by walking up directories. Version 1.1.0 is the latest stable release, with sporadic updates and no active development cadence. It supports both async and sync APIs, returns the parsed config and file path. Compared to similar tools like `find-up` combined with `cosmiconfig`, this package provides a simpler, focused API for Babel config lookup. Requires Node >=10.
Common errors
error Cannot find module 'read-babelrc-up' ↓
cause Package not installed or not in node_modules
fix
Run
npm install read-babelrc-up or check your module path. error ERR_REQUIRE_ESM ↓
cause Using ES module import syntax on a CommonJS-only package
fix
Use require() instead of import, or use dynamic import() with .mjs extension.
error TypeError: readBabelrcUp.sync is not a function ↓
cause Trying to destructure sync as a named export
fix
Use const sync = require('read-babelrc-up').sync; or call readBabelrcUp.sync() directly.
Warnings
deprecated This package is no longer actively maintained; Babel configuration loading is better handled by Babel's own tools or cosmiconfig. ↓
fix Consider using @babel/core's loadPartialConfig or cosmiconfig instead.
gotcha Does not support .babelrc.json, .babelrc.yaml, or other modern Babel config formats. Only .babelrc, .babelrc.js, babel.config.js, and 'babel' key in package.json. ↓
fix Use a more comprehensive config loader like cosmiconfig with babel preset.
breaking Dropped Node.js v6 support in version 0.4.0. ↓
fix Ensure Node.js >=10 is used (current engine requirement).
Install
npm install read-babelrc-up yarn add read-babelrc-up pnpm add read-babelrc-up Imports
- readBabelrcUp wrong
import readBabelrcUp from 'read-babelrc-up'correctconst readBabelrcUp = require('read-babelrc-up') - readBabelrcUp.sync wrong
const { sync } = require('read-babelrc-up')correctconst result = readBabelrcUp.sync({ cwd: '/path' })
Quickstart
const readBabelrcUp = require('read-babelrc-up');
// Async usage
readBabelrcUp({ cwd: process.cwd() })
.then(result => {
console.log(result);
// { babel: { presets: [...] }, path: '/path/to/.babelrc' }
})
.catch(err => console.error(err));
// Sync usage
const result = readBabelrcUp.sync();
console.log(result);
// { babel: { presets: ['es2015', 'react'] }, path: '/Users/akameco/src/my-babel-app/.babelrc' }