Skip to content
Latchkey

React Native Metro "Unable to resolve module" in CI

Metro builds the JS bundle by resolving every import. "Unable to resolve module X from Y" means it could not find that module from the importing file: the dependency is not installed, the path is wrong, or a cached resolution is stale.

What this error means

The bundle step (used by release builds and npx react-native bundle) fails with "error: Unable to resolve module X from Y: X could not be found".

Metro
error: Unable to resolve module ./utils/format from /app/src/App.js:
None of these files exist:
  * src/utils/format(.native|.js|.jsx|.ts|.tsx|.json)
  * src/utils/format/index(...)

Common causes

A missing dependency or wrong import path

The imported package is not in package.json/node_modules, or the relative path/casing does not match a real file.

A stale Metro cache

A cached resolution from a previous tree no longer matches after files moved, so Metro reports the module as unresolvable.

How to fix it

Install the dependency or fix the path

  1. Confirm the package is in package.json and installed via npm ci.
  2. Check the import path and case match an actual file (Linux runners are case-sensitive).
  3. Re-run the bundle.
Terminal
npm ci
npx react-native bundle --platform android --dev false --entry-file index.js --bundle-output bundle.js

Reset the Metro cache

Clear stale resolution caches when files were moved or renamed.

Terminal
npx react-native start --reset-cache

How to prevent it

  • Use exact, case-correct import paths (CI Linux is case-sensitive).
  • Run npm ci so node_modules matches the lockfile.
  • Reset the Metro cache when the file tree changes significantly.

Frequently asked questions

What causes ""Unable to resolve module""?
The imported package is not in package.json/node_modules, or the relative path/casing does not match a real file.
How do I fix "Unable to resolve module"?
Install the dependency or fix the path

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card