Skip to content
Latchkey

Babel ".babelrc: Preset not found" - Fix Config Presets in CI

Babel resolved your .babelrc but could not find a preset or plugin it lists. Babel expands shorthand names (preset-react@babel/preset-react, reactbabel-preset-react), and if the resolved package is not installed - or the name is wrong - the config load fails.

What this error means

The build fails loading the config with .babelrc: Cannot find module '<preset>' or Preset <x> not found. It is deterministic - a missing dependency or wrong name in .babelrc, not flake.

babel output
Error: .babelrc: Cannot find module 'babel-preset-react'
- If you want to resolve "react", use "module:react"
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)
    at loadPreset (.babelrc presets: ["react"])

Common causes

Preset/plugin not installed

A preset or plugin named in .babelrc is not in package.json, so a clean install does not provide it.

Babel 6 name on Babel 7

An old shorthand (react, es2015, babel-preset-*) in .babelrc resolves to a Babel 6-era package that is not installed under Babel 7, which uses scoped @babel/preset-* names.

How to fix it

Use scoped Babel 7 names and install them

Reference @babel/preset-* and install each preset/plugin you list.

Terminal
npm install -D @babel/core @babel/preset-env @babel/preset-react

Correct the .babelrc names

List the resolvable, installed package names.

.babelrc
// .babelrc
{ "presets": ["@babel/preset-env", "@babel/preset-react"] }

How to prevent it

  • Use scoped @babel/* names matched to your @babel/core major.
  • Declare every preset/plugin in devDependencies.
  • Install with npm ci so CI matches the lockfile.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →