Skip to content

Instantly share code, notes, and snippets.

@donpark
Created April 10, 2026 06:12
Show Gist options
  • Select an option

  • Save donpark/c5eda11f3d250b323b40f5dcfbf27f89 to your computer and use it in GitHub Desktop.

Select an option

Save donpark/c5eda11f3d250b323b40f5dcfbf27f89 to your computer and use it in GitHub Desktop.
Metro 'Unable to resolve module' after macOS reboot — a watchman state bug

Metro "Unable to resolve module" after macOS reboot — a watchman state bug

If you're an Expo or React Native developer and Metro suddenly can't resolve modules after a macOS reboot (or upgrade), watchman's stale state is likely the cause.

Symptoms

After rebooting (or upgrading) macOS, Metro fails with:

Unable to resolve module ./node_modules/expo-router/entry

…even though the file exists on disk. Other variants include failure to resolve any node_modules path.

The error typically surfaces as a red screen in the simulator or a bundler failure in the terminal. Nothing in your code changed.

Root cause

Metro uses watchman for fast filesystem lookups. Watchman maintains an in-memory + on-disk state of which directories it's watching and their file trees.

After a macOS reboot or major upgrade, watchman's state can become stale or invalid. When Metro asks watchman to resolve files, watchman may:

  1. Re-watch from the wrong root — e.g. a parent monorepo directory instead of your app directory
  2. Apply stale ignore rules — a .watchmanconfig higher in the tree may have ignore_dirs that exclude your node_modules
  3. Have a corrupted file map — the prior file tree snapshot no longer matches reality

The result: Metro's fileSystemLookup can't find modules that clearly exist on disk. The error message is misleading because it implies a missing file, not a broken filesystem index.

Why monorepo layouts are especially vulnerable

If your repo has a .watchmanconfig at the root with ignore_dirs entries like:

{ "ignore_dirs": ["app/node_modules"] }

…and watchman decides to watch from the root instead of from app/, then your app's entire node_modules becomes invisible to Metro.

Fix

# Nuke all watchman watches
watchman watch-del-all

# Re-enter your app directory and re-establish the watch
cd /path/to/your/app
watchman watch .

Then restart Metro:

npx expo start --clear
# or
npx react-native start --reset-cache

Why this probably affects more people than report it

The typical developer response to "it broke after I restarted my Mac" is to nuke node_modules, reinstall, clear caches, even delete ios/ and regenerate — all of which can incidentally fix the watchman state as a side effect. The root cause never gets identified.

If you're on Expo SDK 55+ with a monorepo-like layout (or any workspace structure with nested node_modules), and things mysteriously break after a reboot, try watchman watch-del-all first before the full nuclear reinstall.

Environment where this was observed

  • macOS 26.4.1 (Tahoe)
  • watchman 2026.03.30.00
  • Expo SDK 55 / React Native 0.83
  • Metro via expo run:ios
  • Monorepo with .watchmanconfig at the repo root
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment