Repository navigation
Bun runtime & bundler in react-native/expo #42111
Replies: 6 comments
|
For a package script, put bun run --bun start
bun run --bun androidThe equivalent persistent setting is: # bunfig.toml
[run]
bun = trueThat setting prepends a {
"scripts": {
"runtime": "node -p \"process.versions.bun || process.versions.node\""
}
}bun run --bun runtimeThere are two important caveats:
So the supported practical setup is References: |
|
I use Bun with Expo/React Native as well, and the main thing to keep in mind is that there are two different concerns here: the runtime used to execute the CLI and the bundler used to build the React Native application. For an Expo project, I'd recommend using Bun primarily as the package manager and script runner: {
"scripts": {
"start": "expo start",
"android": "expo run:android",
"ios": "expo run:ios"
}
}Then: bun install
bun run start
bun run androidIf you specifically want to force a script that would normally invoke Node to run under Bun, the syntax is: bun run --bun start
bun run --bun androidYou can confirm which runtime is actually executing JavaScript with: console.log({
bun: process.versions.bun,
node: process.versions.node,
});However, this does not mean Bun replaces Metro. Expo/React Native still relies on Metro for the application bundle. Metro handles React Native-specific behavior such as platform resolution ( So I would currently structure it as: Trying to replace Metro with So if your goal is simply to use Bun in an Expo project, |
|
Short answer: you can't. React Native apps don't run on Node or Bun on the device. They run on Hermes. The bundle is built by Metro. Bun replaces neither. What Bun is good for in an Expo project: installing packages and running your own scripts. That's it. The moment you run expo start or expo run:android, Metro builds the bundle and Hermes runs it. bun --bun just forces the CLI script itself onto Bun's runtime. It doesn't change what builds or runs your app. |
|
how can i just uninstall Node and use only Bun? , to save my disk space :( |
|
The runtime part and the bundling part are separate things. For the CLI: expo resolves to a node shebang, so plain For the bundle itself: you can't swap it. React Native bundles go through Metro, and RN relies on Metro-specific behavior like platform extensions (.ios.js .native.js) and the Hermes transform. Bun's bundler has no equivalent path and there's no flag to replace it. What I do: Bun as package manager and for scripts, and let expo/metro run on node. — |
|
For the follow-up about uninstalling Node to save disk space, Expo’s Bun guide still lists Node LTS as a prerequisite for |
Uh oh!
There was an error while loading. Please reload this page.
Hey Guy's, How can i use bun runtime with react-native/expo commands e.g.
bun --bun startorbun --bun android. It's still run on node runtime.Also how can we use bun bundler to make react-native/expo bundle?
All reactions