Skip to content
Latchkey

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.js

Common 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

  1. Add babel-loader and @babel/core as devDependencies.
  2. Commit the lockfile change.
  3. Re-run the webpack build.
Terminal
npm install --save-dev babel-loader @babel/core @babel/preset-env

Verify it installs under npm ci

Confirm the loader appears in the lockfile so deterministic CI installs include it.

Terminal
npm ci && npm ls babel-loader

How to prevent it

  • Declare every webpack loader as a devDependency.
  • Keep babel-loader aligned with a compatible @babel/core.
  • Use npm ci so the lockfile drives CI installs.

Related guides

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