Metro can't resolve transitive dependencies when using bun as package manager
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 5.6k
- Forks
- 696
- Avg merge
- 8m
- Merged PRs (30d)
- 7
Description
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
- https://github.com/expo/expo/issues/41994 - The debugging experience issue (how I discovered this)
- https://github.com/expo/expo/issues/41991
Steps to reproduce
- Create an Expo project using bun as package manager
- Have code that imports a transitive dependency (e.g.,
promisewhich is a dependency ofreact-native) - Run
expo run:iosorexpo 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
- Metro could be configured to also look in
node_modules/.bun/ - Expo/RN could list commonly-needed transitive deps like
promiseas peerDependencies - 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with bun using expo run:ios or expo start, importing the transitive promise dependency. Start by tracing Metro's module resolution and compare its search paths with node_modules/.bun/. Done means the transitive dependency resolves under bun without requiring it to be added directly to package.json.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- bun, javascript
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100