Dev dependency expo-network is set to optional, but imported on expo package #2468

Closed
opened 2026-03-13 09:56:36 -05:00 by GiteaMirror · 5 comments
Owner

Originally created by @dccarmo on GitHub (Dec 6, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. Add @better-auth/expo package
  2. Import it
  3. Try to run the Expo project

Current vs. Expected behavior

Current

Metro returns an error: Unable to resolve module expo-network.

Expected

No errors.

What version of Better Auth are you using?

1.4.0

System info

{
  "system": {
    "platform": "darwin",
    "arch": "arm64",
    "version": "Darwin Kernel Version 25.1.0: Mon Oct 20 19:32:41 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T6000",
    "release": "25.1.0",
    "cpuCount": 8,
    "cpuModel": "Apple M1 Pro",
    "totalMemory": "32.00 GB",
    "freeMemory": "0.22 GB"
  },
  "node": {
    "version": "v22.18.0",
    "env": "development"
  },
  "packageManager": {
    "name": "pnpm",
    "version": "10.24.0"
  },
  "frameworks": [
    {
      "name": "react",
      "version": "19.1.0"
    }
  ],
  "databases": null,
  "betterAuth": {
    "version": "1.4.0",
    "config": null
  }
}

Which area(s) are affected? (Select all that apply)

Package

Auth config (if applicable)


Additional context

The expo-network peer dependency is set as optional here: c79b6e3aae/packages/expo/package.json (L81)

But is imported here: c79b6e3aae/packages/expo/src/online-manager.ts (L22)

I'm guessing the fix is to have it not be optional, so the package manager can fetch it when installing dependencies.

Originally created by @dccarmo on GitHub (Dec 6, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce 1. Add `@better-auth/expo` package 2. Import it 3. Try to run the Expo project ### Current vs. Expected behavior **Current** Metro returns an error: `Unable to resolve module expo-network`. **Expected** No errors. ### What version of Better Auth are you using? 1.4.0 ### System info ```bash { "system": { "platform": "darwin", "arch": "arm64", "version": "Darwin Kernel Version 25.1.0: Mon Oct 20 19:32:41 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T6000", "release": "25.1.0", "cpuCount": 8, "cpuModel": "Apple M1 Pro", "totalMemory": "32.00 GB", "freeMemory": "0.22 GB" }, "node": { "version": "v22.18.0", "env": "development" }, "packageManager": { "name": "pnpm", "version": "10.24.0" }, "frameworks": [ { "name": "react", "version": "19.1.0" } ], "databases": null, "betterAuth": { "version": "1.4.0", "config": null } } ``` ### Which area(s) are affected? (Select all that apply) Package ### Auth config (if applicable) ```typescript ``` ### Additional context The `expo-network` peer dependency is set as optional here: https://github.com/better-auth/better-auth/blob/c79b6e3aae409bee98653e3b85a5f24ea3f91663/packages/expo/package.json#L81 But is imported here: https://github.com/better-auth/better-auth/blob/c79b6e3aae409bee98653e3b85a5f24ea3f91663/packages/expo/src/online-manager.ts#L22 I'm guessing the fix is to have it not be optional, so the package manager can fetch it when installing dependencies.
GiteaMirror added the expo label 2026-03-13 09:56:36 -05:00
Author
Owner

@better-auth-agent[bot] commented on GitHub (Dec 6, 2025):

(tag @better-auth-agent if you would like an answer from the Agent)

If you need more help, tag @better-auth-agent in a comment so I can respond.

DiagramDiscordGitHub

Diagram Join Star

@better-auth-agent[bot] commented on GitHub (Dec 6, 2025): (tag @better-auth-agent if you would like an answer from the Agent) _If you need more help, tag @better-auth-agent in a comment so I can respond._ <!-- bot:webhook reply v1 --> [Diagram](https://repodiagrams.s3.eu-north-1.amazonaws.com/skyvern_ultra_detailed_interactive.html) • [Discord](https://discord.gg/fG2XXEuQX3) • [GitHub](https://github.com/Skyvern-AI/Skyvern) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/skyvern_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/fG2XXEuQX3) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/Skyvern-AI/Skyvern)
Author
Owner

@dosubot[bot] commented on GitHub (Dec 6, 2025):

You're right—the error happens because expo-network is marked as optional in @better-auth/expo, but the code always tries to import it at runtime. Metro expects the module to be present, so if it's not installed, you'll see the resolution error.

A recent PR fixed this by making expo-network a required dependency, so newer versions of @better-auth/expo will install it automatically and avoid this issue (PR #5691). For your current version (1.4.0), you can either update to a version after this fix or manually add expo-network to your project's dependencies.

Best practice: any dependency that's always imported (even dynamically) should be required, not optional, to prevent these runtime errors—especially in Expo/React Native projects where the bundler checks for all imports. This same issue previously happened with expo-web-browser and was resolved the same way (see analogous issue).

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Dec 6, 2025): <!-- Answer --> You're right—the error happens because `expo-network` is marked as optional in `@better-auth/expo`, but the code always tries to import it at runtime. Metro expects the module to be present, so if it's not installed, you'll see the resolution error. A recent PR fixed this by making `expo-network` a required dependency, so newer versions of `@better-auth/expo` will install it automatically and avoid this issue ([PR #5691](https://github.com/better-auth/better-auth/pull/5691)). For your current version (1.4.0), you can either update to a version after this fix or manually add `expo-network` to your project's dependencies. Best practice: any dependency that's always imported (even dynamically) should be required, not optional, to prevent these runtime errors—especially in Expo/React Native projects where the bundler checks for all imports. This same issue previously happened with `expo-web-browser` and was resolved the same way ([see analogous issue](https://github.com/better-auth/better-auth/issues/5495)). <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/986461f0-4805-4cda-b769-16c7f620646e?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/986461f0-4805-4cda-b769-16c7f620646e?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/986461f0-4805-4cda-b769-16c7f620646e?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/986461f0-4805-4cda-b769-16c7f620646e?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/986461f0-4805-4cda-b769-16c7f620646e?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/986461f0-4805-4cda-b769-16c7f620646e?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/986461f0-4805-4cda-b769-16c7f620646e?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=You%27re%20right%E2%80%94the%20error%20happens%20because%20%60expo-network%60%20is%20marked%20as%20optional%20in%20%60%40better-auth/expo%60%2C%20but%20the%20code%20always%20tries%20to%20import%20it%20at%20runtime.%20Metro%20expects%20the%20module%20to%20be%20present%2C%20so%20if%20it%27s%20not%20installed%2C%20you%27ll%20see%20the%20resolution%20error.%0A%0AA%20recent%20PR%20fixed%20this%20by%20making%20%60expo-network%60%20a%20required%20dependency%2C%20so%20newer%20versions%20of%20%60%40better-auth/expo%60%20will%20install%20it%20automatically%20and%20avoid%20this%20issue%20%28%5BPR%20%235691%5D%28https%3A//github.com/better-auth/better-auth/pull/5691%29%29.%20For%20your%20current%20version%20%281.4.0%29%2C%20you%20can%20either%20update%20to%20a%20version%20after%20this%20fix%20or%20manually%20add%20%60expo-network%60%20to%20your%20project%27s%20dependencies.%0A%0ABest%20practice%3A%20any%20dependency%20that%27s%20always%20imported%20%28even%20dynamically%29%20should%20be%20required%2C%20not%20optional%2C%20to%20prevent%20these%20runtime%20errors%E2%80%94especially%20in%20Expo/React%20Native%20projects%20where%20the%20bundler%20checks%20for%20all%20imports.%20This%20same%20issue%20previously%20happened%20with%20%60expo-web-browser%60%20and%20was%20resolved%20the%20same%20way%20%28%5Bsee%20analogous%20issue%5D%28https%3A//github.com/better-auth/better-auth/issues/5495%29%29.)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/6564)
Author
Owner

@SergioJuniorCE commented on GitHub (Jan 7, 2026):

bump?

@SergioJuniorCE commented on GitHub (Jan 7, 2026): bump?
Author
Owner

@hubingkang commented on GitHub (Jan 12, 2026):

same problem

@hubingkang commented on GitHub (Jan 12, 2026): same problem
Author
Owner

@bytaesu commented on GitHub (Feb 3, 2026):

Note

https://www.better-auth.com/docs/integrations/expo#install-client-dependencies

Hi everyone,

We use expo-network on the Expo client side, and we updated the documentation accordingly. Based on my testing, the issue is resolved when following the latest guide.

I'm closing this. Feel free to reopen this or mention me if the issue persists.

@bytaesu commented on GitHub (Feb 3, 2026): > [!NOTE] > https://www.better-auth.com/docs/integrations/expo#install-client-dependencies Hi everyone, We use `expo-network` on the Expo client side, and we updated the documentation accordingly. Based on my testing, the issue is resolved when following the latest guide. I'm closing this. Feel free to reopen this or mention me if the issue persists.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#2468