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".
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
- Confirm the package is in package.json and installed via
npm ci. - Check the import path and case match an actual file (Linux runners are case-sensitive).
- Re-run the bundle.
npm ci
npx react-native bundle --platform android --dev false --entry-file index.js --bundle-output bundle.jsReset the Metro cache
Clear stale resolution caches when files were moved or renamed.
npx react-native start --reset-cacheHow 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.