APK errors

Metro: Unable to resolve module

Error text

error: Error: Unable to resolve module ./components/Header from /app/src/App.js:
None of these files exist: * components/Header(.native|.android.ts|.ts|.js|.json)

Cause

The Metro bundler cannot find the imported file or package. A wrong name or path, letter case, or a half-finished install may be behind it.

Step-by-step fix

  1. Compare the path in the error with the real file name; Header and header differ.
  2. Run npm install for packages and confirm they are in package.json.
  3. Reset the cache with npx expo start --clear.
  4. Delete node_modules and install again.
  5. In a monorepo check watchFolders in metro.config.js.

Example commands

npx expo start --clear
npx react-native start --reset-cache
rm -rf node_modules && npm install
watchman watch-del-all

How to prevent it

Name files consistently in one letter case; it matters on Linux.

Author and license: Nibras Code