πŸ”§ Error Fixes
Β· 1 min read

Webpack: Module Not Found β€” Can't Resolve β€” How to Fix It


Module not found: Error: Can't resolve './components/Header'

Webpack can’t find the file you’re importing.

Fix 1: Check the file path

// ❌ Wrong path or missing extension
import Header from './components/Header';

// βœ… Check the actual file location
import Header from './components/Header.jsx';

Fix 2: Configure resolve extensions

// webpack.config.js
module.exports = {
  resolve: {
    extensions: ['.js', '.jsx', '.ts', '.tsx'],
  },
};

Fix 3: Missing package

npm install missing-package

Fix 4: Case sensitivity

File systems on Linux are case-sensitive:

// ❌ Wrong case (works on Mac, fails on Linux)
import Header from './components/header';

// βœ… Match exact filename
import Header from './components/Header';

Related: Webpack: ChunkLoadError β€” Loading Chunk Failed β€” How to Fix It

Related: TypeScript: Cannot Find Module β€” How to Fix It