webpack "export 'X' was not found in" - Fix Bad Named Imports
webpack resolved the module but the specific named export you imported does not exist on it. The path is fine; the binding is wrong - a typo, a default-vs-named mismatch, or an export removed by a version bump.
What this error means
The build fails (or warns then fails on strict CI) with export 'X' (imported as 'X') was not found in '<module>', often listing the names that *are* exported. It is deterministic.
ERROR in ./src/cart.js 2:0-30
export 'addItem' (imported as 'addItem') was not found in './store'
(possible exports: addToCart, removeFromCart)Common causes
Named import does not match the export
You imported { addItem } but the module exports addToCart. A typo or a renamed export breaks the named binding even though the file resolves.
Default vs named confusion
Importing { Thing } from a module that only has a default export (or vice versa) leaves the named binding undefined and webpack reports it missing.
Export removed or renamed by an upgrade
A dependency major version dropped or renamed an export; your import still references the old name.
How to fix it
Import the name the module actually exports
Match the import to the real export, fixing default vs named.
// wrong:
import { addItem } from './store'
// right (named export is addToCart):
import { addToCart } from './store'
// or a default export:
import store from './store'Confirm the export after a dependency bump
- Open the module (or its types) and read the actual export list webpack printed.
- Update your import to the new name if an upgrade renamed it.
- Run a type-check (
tsc --noEmit) so missing exports surface before the bundle step.
How to prevent it
- Let TypeScript or
eslint-plugin-importcatch missing named exports before build. - Read changelogs for renamed/removed exports when bumping a dependency major.
- Prefer editor auto-import so export names are spelled correctly.