Webpack "Can't resolve 'babel-loader'" in CI
Webpack resolves each loader named in a rule as a module. "Can't resolve 'babel-loader'" means the loader package referenced in the config is not installed in the runner's node_modules.
What this error means
The webpack build fails with "Module not found: Error: Can't resolve 'babel-loader'" pointing at the rule that uses it.
babel
Module not found: Error: Can't resolve 'babel-loader' in
'/home/runner/work/app/app'
@ ./src/index.jsCommon causes
babel-loader is not in package.json
The loader was installed locally but never recorded, so a clean CI install does not fetch it.
A version mismatch with @babel/core
babel-loader needs a compatible @babel/core peer; an incomplete install can leave the loader unresolvable.
How to fix it
Install babel-loader and its peer
- Add babel-loader and @babel/core as devDependencies.
- Commit the lockfile change.
- Re-run the webpack build.
Terminal
npm install --save-dev babel-loader @babel/core @babel/preset-envVerify it installs under npm ci
Confirm the loader appears in the lockfile so deterministic CI installs include it.
Terminal
npm ci && npm ls babel-loaderHow to prevent it
- Declare every webpack loader as a devDependency.
- Keep babel-loader aligned with a compatible @babel/core.
- Use
npm ciso the lockfile drives CI installs.
Related guides
Babel "Cannot find module '@babel/core'" running the CLI in CIFix "Cannot find module '@babel/core'" in CI - @babel/cli or a loader needs @babel/core as a peer, but it is…
Babel "Support for the experimental syntax ... isn't currently enabled" in CIFix Babel "Support for the experimental syntax 'X' isn't currently enabled" in CI - the source uses syntax th…
Tailwind "Cannot find module 'tailwindcss'" in CIFix "Cannot find module 'tailwindcss'" in CI - the PostCSS config references the tailwindcss plugin but the p…