The "Module not found" error occurs when React's build tool (Webpack/Vite) cannot locate a file or package you're trying to import. This is a compile-time error that prevents your app from building.
# For missing packages
npm install package-name
# For path issues "" check the exact path
ls src/components/ # Verify file exists and check exact name
# Clean install if node_modules is corrupted
rm -rf node_modules package-lock.json
npm install
import axios from 'axios'; // Module not found: Can't resolve 'axios'
import { motion } from 'framer-motion'; // Not installed!
# Install the missing package
npm install axios
npm install framer-motion
# Or install multiple at once
npm install axios framer-motion react-router-dom
# Verify it's in package.json after installing
cat package.json | grep axios
// File is at: src/components/Button/Button.jsx
import Button from './Button'; // Wrong Wrong path
import Button from '../components/btn'; // Wrong Wrong name
import Button from './components/Button' // Wrong Missing leading ./
// Correct Correct relative path from current file
import Button from '../components/Button/Button';
// Correct Or if there's an index.js in the folder
import Button from '../components/Button'; // Resolves to index.js
// Correct Use path aliases (configure in vite.config.js or jsconfig.json)
import Button from '@/components/Button';
// File on disk: UserProfile.jsx
import UserProfile from './userprofile'; // Wrong Works on Windows, fails on Linux/Mac!
import UserProfile from './Userprofile'; // Wrong Wrong case
// Correct Match exact case of filename
import UserProfile from './UserProfile'; // Exact match
// Best practice: Use PascalCase for component files
// UserProfile.jsx, Button.jsx, NavBar.jsx
git clone https://github.com/user/project
cd project
npm start # Module not found errors everywhere!
git clone https://github.com/user/project
cd project
npm install # Correct Install all dependencies first!
npm start
Try this next
0 of 2 completed
The import path still points to the old filename, old folder, or old letter casing. React's build tool resolves exactly what the import string says; it does not know that Header.jsx was renamed to SiteHeader.jsx unless every import is updated.
Windows usually treats Button.jsx and button.jsx as the same path, while Linux treats them as different files. A deployment server, CI runner, or Docker container may therefore fail even though local development worked.
In a Vite React project, configure resolve.alias in vite.config.js and mirror the alias in jsconfig.json or tsconfig.json so the editor understands it too. For example, @ can point to src.
Explore 500+ free tutorials across 20+ languages and frameworks.