React Native 0.72 shipped a Metro release that finally makes two long-requested resolver features usable in normal projects: stable support for symlinks (the thing monorepos and npm/yarn link workflows depend on) and opt-in support for the Node-style exports field in package.json. In practice this means fewer "Unable to resolve module" errors in workspaces, and libraries that only declare their entry points through exports now resolve instead of silently falling back to main. The catch is that symlink support has to be turned on deliberately in metro.config.js, and package exports are still behind a flag, so most "it changed everything" surprises come from config that was written for older Metro.
The overall task is small: enable unstable_enableSymlinks, decide whether to enable unstable_enablePackageExports, then make sure your watched folders and custom resolvers still agree with the new behaviour.
What You'll Need
- A project running React Native 0.72, or one you are upgrading to it, with the Metro version that ships alongside it (do not mix in an older
metro-configmanually). - Node.js installed and your package manager working (
npm,yarnorpnpm). - A terminal open at the project root, plus an editor for
metro.config.js. - If you use a monorepo, the paths to your workspace packages and to the shared
node_modulesfolder. - A working
npx react-native start --reset-cachecommand, so you can reproduce issues from a clean cache.
Step-by-Step
Confirm which Metro you are running. Check the
metroandmetro-configversions in your lockfile or withnpm ls metro. React Native 0.72 pins a matching Metro; if your lockfile shows an older Metro hoisted from a dependency, fix that first by reinstalling, because the symlink and exports behaviour simply is not present in older versions.Open (or create)
metro.config.js. React Native projects normally have this file at the root. If it is missing, generate one from the default template by runningnpx react-native bundle --helpto confirm the CLI is working, then create the file yourself and export a configuration object. Keep it a plainmodule.exports = { ... }unless you already use themergeConfighelper from@react-native/metro-config.Enable symlinks. Add
unstable_enableSymlinks: trueto the top level of the config object (not insideresolver). Despite theunstableprefix used at the time of the release, this is the switch that tells Metro to follow symlinked folders and to key its cache on file identity rather than absolute path. Without it, a package linked intonode_modulesis not descended into, which is why imports from a linked workspace package fail.Add any extra watch folders. Metro only crawls the project root by default. In a monorepo, set
watchFoldersto the absolute paths of the sibling packages (and, if your manager hoists, the rootnode_modules). Usepath.resolve(__dirname, '../packages')style paths so the config stays portable between machines.Decide on package exports. Add
unstable_enablePackageExports: trueinside theresolverblock if your dependencies rely on theexportsmap. When enabled, Metro reads the"exports"field of a package and, where a"react-native"condition is declared, prefers it overmain. Leave it off if some dependency has a broken or overly strictexportsmap, because a bad map can block subpath imports that used to work.If you are on the New Architecture or use the
react-nativecondition, set the condition list.resolver.unstable_conditionNamestakes an array such as['require', 'react-native'], andunstable_conditionsByPlatformmaps platform names to extra conditions. Metro already resolves platform-specific files through its own extension list, so you normally only touch this when a library documents a custom condition.Reconcile custom resolvers. If you maintain
resolver.resolveRequestor use a plugin that redirects modules, make sure it returnsnullto fall through to Metro's default instead of re-implementing lookup. Symlink-aware resolution happens inside Metro's default resolver, so a hand-written resolver that builds paths manually can quietly bypass it.Restart with a clean cache. Stop the bundler, then run
npx react-native start --reset-cache. The cache is keyed on resolution results, and stale entries from before you flipped the flags will keep reproducing old errors until you clear them.Verify symlinks work. Import a file from the linked package in a screen, then rebuild. A successful resolve plus hot reload edits from the linked package proving the watcher follows the symlink confirms both halves of symlink support. If edits do not trigger a reload, the folder is missing from
watchFolders.Verify exports behaviour. Find a dependency whose
package.jsonhas anexportsmap and check that the file it points to (often a separate ESM or React Native build) is what ends up in the bundle. A quick way is to add a temporaryconsole.login a file that only one of the entries exports, or inspect the bundle for the expected file name.Do a production build. Run your release bundle (
npx react-native bundle --platform android --dev false, or your normal release build) to catch resolution differences that only appear without the dev server, such as a package that resolves in development through a fallback but fails in a release bundle.
Common Mistakes
- Putting
unstable_enableSymlinksinsideresolver. It belongs at the top level of the config; nested, it is ignored without any warning. - Forgetting
watchFolders. Symlinked packages resolve but do not trigger rebuilds, which looks like flaky hot reload rather than a configuration problem. - Enabling package exports and assuming every subpath still works. Some packages list only some entries in
exports; anything not listed is blocked, which is a package authoring issue, not a Metro bug. - Clearing the cache with
rm -rf node_modulesbut not restarting the bundler with--reset-cache. The transformed module cache survives that and keeps serving stale resolutions. - Mixing package managers in a monorepo. A
yarnworkspace with annpm installat the root produces duplicate copies and broken links that no Metro setting can fully rescue. - Copying an old community config that sets
resolver.blacklistREpatterns for duplicate React copies. With symlinks enabled, path-based blacklists may match the linked path and exclude the package you wanted. - Assuming exports support also handles conditional
import/requiredifferences in CommonJS the way Node does. Metro still bundles for a runtime without Node's module system; unusual dual-package setups may need a resolver hint.
Tips
- Turn on symlinks even if you do not use a monorepo today. It removes a class of duplicate-module bugs, including the "two copies of React" error.
- Keep the flags visible and commented in
metro.config.js. Theunstable_prefix signals the option name may change in a later release, so a comment noting why each one is set saves rework during upgrades. - Test with
--reset-cacheafter every config edit. Metro does not watch its own configuration reliably in all setups. - If a package breaks only with exports enabled, check whether it also ships a
react-nativefield. Turning exports back off is a legitimate temporary fix while you open an issue with the package maintainer. - Use
npx react-native configto see what the CLI thinks your project looks like; a mismatch between that output andmetro.config.jsexplains many confusing resolution failures.
Troubleshooting
Still "Unable to resolve module" after enabling symlinks. Confirm the config file Metro is actually loading is the one you edited: run the dev server and look at the logged config path. Then verify the flag is at the top level and that the linked folder is under a path in watchFolders or the project root.
A workspace package resolves but its own dependencies do not. The dependency was probably installed into the package's private node_modules rather than hoisted, or vice versa. Add the hoisted root node_modules to watchFolders and reinstall cleanly.
Edits in the linked package do not reload. Watch folders are the cause almost every time. Add the package root, restart with --reset-cache and edit again.
Exports flipped a working import into a failure. Set unstable_enablePackageExports back to false, clear the cache, and confirm the app builds. Then reintroduce it package by package by testing your dependency set, and pin or patch the offending package if it lacks the entry you import.
Resolution works in Metro but not in a release build, or the reverse. Check for environment-specific config: Babel plugins, a metro.config.js branch on process.env, or different lockfile state on CI. Run the same install command and the same config on both.
Nothing helps. Delete the Metro cache directory (node_modules/.cache/metro on many setups), reinstall dependencies from the lockfile, and start with --reset-cache. Only then investigate resolver plugins, disabling them one at a time.
Frequently Asked Questions
Do I have to enable symlinks for normal projects?
No. A project that only uses packages installed normally resolves fine without it. It matters for linked packages, monorepos and pnpm's symlinked store layout.
Why is the option named with unstable_?
Because the option name and internals may change in later Metro releases. The behaviour itself is intended for real use; only the flag name is provisional.
Does enabling package exports break older packages?
It can, if a package declares an exports map that omits entries people import directly. Packages with no exports field are resolved the old way, so they usually keep working.
Do these changes affect hot reload or fast refresh?
Symlink support does, indirectly: fast refresh needs the file watcher to see the linked folder. Package exports only affects resolution, not reloading.
Can I use both flags at once?
Yes. They address different parts of resolution and are routinely enabled together in workspaces. Enable them in separate steps so you can tell which one caused a regression.
Where do labels and option names differ?
Metro config keys can change slightly between releases, so check the Metro documentation for the exact version bundled with your React Native release if a key is rejected.