Skip to main content
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_FOUND

Quick 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
  1. 1Check if node_modules exists
  2. 2Verify package.json has the dependency
  3. 3Check import statement for typos
  4. 4Verify module name case matches installed package
  5. 5Check if working directory is correct

Solutions

Solution 1: Install missing module
  1. 1Identify the missing module from error message
  2. 2Install the module using npm or yarn
  3. 3Verify installation in node_modules
  4. 4Restart the application

Commands to Run

Check package.json for version constraints

npm install module-name

Some modules require peer dependencies

yarn add module-name
npm install
Solution 2: Reinstall all dependencies
  1. 1Delete node_modules and package-lock.json
  2. 2Run npm install to reinstall everything
  3. 3Verify all dependencies are installed
  4. 4Restart application

Commands to Run

This can take time for large projects

rm -rf node_modules package-lock.json

May resolve dependency conflicts

npm install
Solution 3: Fix import path or name
  1. 1Check import statement for typos
  2. 2Verify module name case matches package.json
  3. 3Check relative import paths
  4. 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+

Was this helpful?