high

Cannot find module './Component'

Jest could not resolve a module import. The file may not exist, the path may be wrong, or the module resolution config may be misconfigured.

Common Causes

  1. 1File path is incorrect or has a typo
  2. 2Path aliases (e.g., @/) are not configured in Jest
  3. 3File extension is missing and not in the resolve list
  4. 4Module is not installed (missing from node_modules)
  5. 5Jest's moduleNameMapper config doesn't match your bundler's aliases

How to Fix

Configure moduleNameMapper for path aliases

// jest.config.ts
export default {
  moduleNameMapper: {
    '^@/(.*)$': '<rootDir>/src/$1',
    '\\.(css|less|scss)$': 'identity-obj-proxy',
  },
};

Map path aliases to their actual paths so Jest can resolve imports the same way your bundler does.

Add moduleFileExtensions

// jest.config.ts
export default {
  moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'],
};

Tell Jest which file extensions to try when resolving imports without explicit extensions.

How ObserveOne Helps

ObserveOne validates test configurations and catches module resolution issues before CI/CD runs.

Start Monitoring Free

Related Errors