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, react → babel-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.
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.
npm install -D @babel/core @babel/preset-env @babel/preset-reactCorrect the .babelrc names
List the resolvable, installed package names.
// .babelrc
{ "presets": ["@babel/preset-env", "@babel/preset-react"] }How to prevent it
- Use scoped
@babel/*names matched to your@babel/coremajor. - Declare every preset/plugin in
devDependencies. - Install with
npm ciso CI matches the lockfile.