nodejsbeginnerdependenciesVerified
Node.js Module Not Found: Causes and Fixes
Last reviewed: 9/14/2026
3 solutions
Exact Error Message
Error: Cannot find module 'module-name' or MODULE_NOT_FOUNDQuick Fix
Install the missing module: npm install module-name or npm install.
What This Error Means
MODULE_NOT_FOUND occurs when Node.js cannot find a module that your code is trying to import. This can happen if the module isn't installed, isn't in the node_modules directory, or has a case-sensitivity issue.
Common Symptoms
- •Application crashes on startup
- •Error about missing module
- •Import statement fails
- •Cannot find dependency
Common Causes
- •Module not installed
- •node_modules directory missing
- •package.json missing dependencies
- •Case sensitivity in module name
- •Wrong import path
- •Monorepo configuration issue
Diagnostic Steps
- 1Check if node_modules exists
- 2Verify package.json has the dependency
- 3Check import statement for typos
- 4Verify module name case matches installed package
- 5Check if working directory is correct
Solutions
Solution 1: Install missing module
- 1Identify the missing module from error message
- 2Install the module using npm or yarn
- 3Verify installation in node_modules
- 4Restart the application
Commands to Run
Check package.json for version constraints
npm install module-nameSome modules require peer dependencies
yarn add module-namenpm installSolution 2: Reinstall all dependencies
- 1Delete node_modules and package-lock.json
- 2Run npm install to reinstall everything
- 3Verify all dependencies are installed
- 4Restart application
Commands to Run
This can take time for large projects
rm -rf node_modules package-lock.jsonMay resolve dependency conflicts
npm installSolution 3: Fix import path or name
- 1Check import statement for typos
- 2Verify module name case matches package.json
- 3Check relative import paths
- 4Verify working directory is project root
Prevention Tips
- ✓Commit package-lock.json
- ✓Use npm ci for production installs
- ✓Run npm install after pulling changes
- ✓Check dependencies before deployment
- ✓Use dependency management tools
Version Notes: Applies to Node.js 12+ with npm 6+
Official Documentation
Related Errors
Was this helpful?