Skip to content
Latchkey

Babel "Cannot find module '@babel/...'" - Fix Missing Presets in CI

Babel tried to load a preset or plugin named in your config and could not find it in node_modules. The config references a package that was never installed - or only installed locally and not declared as a dependency.

What this error means

The build fails with Cannot find module '@babel/preset-env' (or preset-react, a plugin, etc.) referenced from your Babel config. It is deterministic - a missing dependency, not flake.

babel output
Error: Cannot find module '@babel/preset-react'
Require stack:
- /app/node_modules/@babel/core/lib/config/files/plugins.js
  at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)
  at babel.config.js (presets: ['@babel/preset-react'])

Common causes

Preset/plugin not installed

The config lists a preset (@babel/preset-env, @babel/preset-react, @babel/preset-typescript) or plugin that is not in package.json, so a clean install does not provide it.

Wrong package name or version

A typo, an old babel-preset-* (Babel 6) name on Babel 7, or a major-version mismatch between @babel/core and a preset makes resolution fail.

How to fix it

Install the presets/plugins you reference

Add every preset and plugin named in the Babel config as a dev dependency.

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

Use the correct Babel 7 names

Reference scoped @babel/* packages, matched to your @babel/core major.

babel.config.js
// babel.config.js
module.exports = {
  presets: ['@babel/preset-env', '@babel/preset-react', '@babel/preset-typescript'],
}

How to prevent it

  • Declare every Babel preset/plugin in devDependencies.
  • Install with npm ci so CI matches the lockfile.
  • Keep @babel/core and presets on compatible major versions.

Frequently asked questions

What causes ""Cannot find module '@babel/...'""?
The config lists a preset (@babel/preset-env, @babel/preset-react, @babel/preset-typescript) or plugin that is not in package.json, so a clean install does not provide it.
How do I fix "Cannot find module '@babel/...'"?
Add every preset and plugin named in the Babel config as a dev dependency.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card