Skip to content

Metro can't resolve transitive dependencies when using bun as package manager #1636

Description

@marcospgp

Summary

When using bun as package manager, Metro bundler cannot resolve transitive dependencies because bun stores them in node_modules/.bun/ rather than hoisting them to node_modules/.

Related

Steps to reproduce

  1. Create an Expo project using bun as package manager
  2. Have code that imports a transitive dependency (e.g., promise which is a dependency of react-native)
  3. Run expo run:ios or expo start

Expected behavior

Metro should be able to resolve promise since it's a dependency of react-native which is installed.

Actual behavior

Unable to resolve module promise/setimmediate/rejection-tracking from /path/to/file.ts:
promise/setimmediate/rejection-tracking could not be found within the project or in these directories:
  node_modules
  ../node_modules

The package exists at node_modules/.bun/promise@8.3.0/node_modules/promise but Metro doesn't look there.

Workaround

Add transitive dependencies as direct dependencies in package.json:

"promise": "^8.3.0"

Environment

  • bun: 1.x
  • expo: 54.0.30
  • react-native: 0.81.5

Possible solutions

  1. Metro could be configured to also look in node_modules/.bun/
  2. Expo/RN could list commonly-needed transitive deps like promise as peerDependencies
  3. Documentation warning about bun compatibility

Notes

This differs from npm/yarn behavior where transitive dependencies are hoisted to root node_modules/ and are resolvable by any package. Bun is increasingly popular so this may affect more users.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions