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.
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'])Diagnose it: is it resolution, transform, or memory?
Bundler failures in CI fall into three families and the error text often points at the wrong one. A module that resolves on your machine and not on the runner is nearly always case sensitivity or a missing optional dependency; a transform error is a config or version mismatch; and an unexplained kill with no stack is the out-of-memory reaper, not a build error at all.
# 1. resolution: does the file exist with EXACTLY that case?
git ls-files | grep -i "the/imported/path"
# 2. transform: what versions is CI actually resolving?
npm ls webpack vite rollup esbuild typescript 2>/dev/null | head -20
# 3. memory: was it killed rather than failed?
# exit 137 = SIGKILL (OOM). Nothing in the bundler log will explain it.
node --max-old-space-size=4096 node_modules/.bin/vite buildCommon 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.
npm install -D @babel/core @babel/preset-env @babel/preset-react @babel/preset-typescriptUse the correct Babel 7 names
Reference scoped @babel/* packages, matched to your @babel/core major.
// babel.config.js
module.exports = {
presets: ['@babel/preset-env', '@babel/preset-react', '@babel/preset-typescript'],
}Make the build reproducible before you debug it
- Pin the Node major in
setup-nodeand inengines. A bundler that resolves native bindings will pick a different prebuilt binary across majors. - Delete
node_moduleslocally and reinstall from the lockfile before concluding the runner is at fault; most "works locally" reports are stale local state. - Set
CI=truelocally to reproduce. Several toolchains change behaviour under it, including treating warnings as errors. - Exit code 137 is an out-of-memory kill. Raise
--max-old-space-sizeor move to a larger runner rather than searching the bundler config.
How to prevent it
- Declare every Babel preset/plugin in
devDependencies. - Install with
npm ciso CI matches the lockfile. - Keep
@babel/coreand presets on compatible major versions.