[GH-ISSUE #4510] Error after upgrading to better-auth 1.3.8: "attempted to import Node standard library module 'node:buffer'" in React Native/Expo #18595

Closed
opened 2026-04-15 17:07:56 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @gee1k on GitHub (Sep 8, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/4510

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Description

After upgrading better-auth from a previous version to 1.3.8, I'm encountering build errors in my React Native/Expo project. The error indicates that Node.js standard library modules are being imported, which are not available in the React Native runtime.

Error Messages

WARN  Attempted to import the module "workspace/node_modules/@noble/ciphers/crypto.js" which is not listed in the "exports" of "workspace/node_modules/@noble/ciphers" under the requested subpath "./crypto.js". Falling back to file-based resolution. Consider updating the call site or asking the package maintainer(s) to expose this API.

WARN  Attempted to import the module "workspace/node_modules/@noble/hashes/crypto.js" which is not listed in the "exports" of "workspace/node_modules/@noble/hashes" under the requested subpath "./crypto.js". Falling back to file-based resolution. Consider updating the call site or asking the package maintainer(s) to expose this API.

iOS Bundling failed 13344ms node_modules/expo-router/entry.js (4666 modules)
The package at "node_modules/jose/dist/node/cjs/runtime/base64url.js" attempted to import the Node standard library module "node:buffer".
It failed because the native React runtime does not include the Node standard library.

Steps to Reproduce

  1. Upgrade better-auth to version 1.3.8
  2. Build the React Native/Expo project
  3. Error occurs during bundling

Current vs. Expected behavior

The project should build successfully without Node.js standard library import errors, as it did in previous versions.

What version of Better Auth are you using?

1.3.8

System info

{
  "system": {
    "platform": "darwin",
    "arch": "arm64",
    "version": "Darwin Kernel Version 24.5.0: Tue Apr 22 19:53:27 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T6041",
    "release": "24.5.0",
    "cpuCount": 12,
    "cpuModel": "Apple M4 Pro",
    "totalMemory": "48.00 GB",
    "freeMemory": "0.18 GB"
  },
  "node": {
    "version": "v22.17.1",
    "env": "development"
  },
  "packageManager": {
    "name": "npm",
    "version": "10.9.2"
  },
  "frameworks": [
    {
      "name": "react",
      "version": "19.0.0"
    }
  ],
  "databases": [
    {
      "name": "drizzle",
      "version": "^0.44.5"
    }
  ],
  "betterAuth": {
    "version": "1.0.0",
    "config": null
  }
}

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

Client

Auth config (if applicable)

import { betterAuth } from "better-auth"
export const auth = betterAuth({
  emailAndPassword: {  
    enabled: true
  },
});

Additional context

This issue seems related to the jose package and @noble/ciphers/@noble/hashes dependencies attempting to import Node.js modules that are not available in React Native environment. The error suggests that better-auth 1.3.8 might have introduced new dependencies or changed how existing dependencies are used, causing compatibility issues with React Native.

Would it be possible to ensure React Native compatibility by using appropriate polyfills or alternative implementations for the React Native environment?

Originally created by @gee1k on GitHub (Sep 8, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/4510 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce ### Description After upgrading better-auth from a previous version to 1.3.8, I'm encountering build errors in my React Native/Expo project. The error indicates that Node.js standard library modules are being imported, which are not available in the React Native runtime. ### Error Messages ``` WARN Attempted to import the module "workspace/node_modules/@noble/ciphers/crypto.js" which is not listed in the "exports" of "workspace/node_modules/@noble/ciphers" under the requested subpath "./crypto.js". Falling back to file-based resolution. Consider updating the call site or asking the package maintainer(s) to expose this API. WARN Attempted to import the module "workspace/node_modules/@noble/hashes/crypto.js" which is not listed in the "exports" of "workspace/node_modules/@noble/hashes" under the requested subpath "./crypto.js". Falling back to file-based resolution. Consider updating the call site or asking the package maintainer(s) to expose this API. iOS Bundling failed 13344ms node_modules/expo-router/entry.js (4666 modules) The package at "node_modules/jose/dist/node/cjs/runtime/base64url.js" attempted to import the Node standard library module "node:buffer". It failed because the native React runtime does not include the Node standard library. ``` ### Steps to Reproduce 1. Upgrade better-auth to version 1.3.8 2. Build the React Native/Expo project 3. Error occurs during bundling ### Current vs. Expected behavior The project should build successfully without Node.js standard library import errors, as it did in previous versions. ### What version of Better Auth are you using? 1.3.8 ### System info ```bash { "system": { "platform": "darwin", "arch": "arm64", "version": "Darwin Kernel Version 24.5.0: Tue Apr 22 19:53:27 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T6041", "release": "24.5.0", "cpuCount": 12, "cpuModel": "Apple M4 Pro", "totalMemory": "48.00 GB", "freeMemory": "0.18 GB" }, "node": { "version": "v22.17.1", "env": "development" }, "packageManager": { "name": "npm", "version": "10.9.2" }, "frameworks": [ { "name": "react", "version": "19.0.0" } ], "databases": [ { "name": "drizzle", "version": "^0.44.5" } ], "betterAuth": { "version": "1.0.0", "config": null } } ``` ### Which area(s) are affected? (Select all that apply) Client ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" export const auth = betterAuth({ emailAndPassword: { enabled: true }, }); ``` ### Additional context This issue seems related to the `jose` package and `@noble/ciphers`/`@noble/hashes` dependencies attempting to import Node.js modules that are not available in React Native environment. The error suggests that better-auth 1.3.8 might have introduced new dependencies or changed how existing dependencies are used, causing compatibility issues with React Native. Would it be possible to ensure React Native compatibility by using appropriate polyfills or alternative implementations for the React Native environment?
GiteaMirror added the locked label 2026-04-15 17:07:57 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Sep 8, 2025):

Hi @gee1k! I'm Dosu and I’m helping the better-auth team.

This error is caused by the jose package (and sometimes other dependencies like @noble/ciphers/@noble/hashes) importing Node.js standard library modules such as node:buffer, which aren't available in React Native/Expo environments. This issue was introduced in recent versions of better-auth, including 1.3.8, due to changes in how dependencies are bundled and used in client code (source, source).

Workarounds:

  1. Add a jose override in your package.json to force a compatible version (e.g. "overrides": { "jose": "^6.1.0" }).
  2. Install react-native-webcrypto and import it at the top level of your app before activating any better-auth plugins (source).
  3. If you use plugins from better-auth/client/plugins, avoid those that depend on jose or Node.js built-ins, or move that logic to your backend (source).

Important: These workarounds may not fully resolve the issue if other dependencies require Node.js built-ins. The recommended approach for React Native/Expo is to keep authentication logic that depends on Node.js modules on the backend, and only use browser-safe/client-safe code in your mobile app.

If you are importing from the default entrypoint, switch to the explicit client entrypoint:

import { betterAuth } from 'better-auth/client'

to avoid server-only code in your bundle (source).

Let me know if you need help with a specific plugin or setup!

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

<!-- gh-comment-id:3264588476 --> @dosubot[bot] commented on GitHub (Sep 8, 2025): <!-- Greeting --> Hi @gee1k! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the better-auth team. <!-- Answer --> This error is caused by the `jose` package (and sometimes other dependencies like `@noble/ciphers`/`@noble/hashes`) importing Node.js standard library modules such as `node:buffer`, which aren't available in React Native/Expo environments. This issue was introduced in recent versions of better-auth, including 1.3.8, due to changes in how dependencies are bundled and used in client code ([source](https://github.com/better-auth/better-auth/issues/4471), [source](https://github.com/better-auth/better-auth/issues/4496)). **Workarounds:** 1. Add a `jose` override in your `package.json` to force a compatible version (e.g. `"overrides": { "jose": "^6.1.0" }`). 2. Install `react-native-webcrypto` and import it at the top level of your app before activating any better-auth plugins ([source](https://github.com/better-auth/better-auth/issues/4422)). 3. If you use plugins from `better-auth/client/plugins`, avoid those that depend on `jose` or Node.js built-ins, or move that logic to your backend ([source](https://github.com/better-auth/better-auth/issues/4471)). **Important:** These workarounds may not fully resolve the issue if other dependencies require Node.js built-ins. The recommended approach for React Native/Expo is to keep authentication logic that depends on Node.js modules on the backend, and only use browser-safe/client-safe code in your mobile app. If you are importing from the default entrypoint, switch to the explicit client entrypoint: ```js import { betterAuth } from 'better-auth/client' ``` to avoid server-only code in your bundle ([source](https://github.com/better-auth/better-auth/issues/3498)). Let me know if you need help with a specific plugin or setup! <!-- 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/0a0add59-b852-44a0-a3df-1c0eb8d4cd6f?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/0a0add59-b852-44a0-a3df-1c0eb8d4cd6f?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/0a0add59-b852-44a0-a3df-1c0eb8d4cd6f?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/0a0add59-b852-44a0-a3df-1c0eb8d4cd6f?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/0a0add59-b852-44a0-a3df-1c0eb8d4cd6f?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/0a0add59-b852-44a0-a3df-1c0eb8d4cd6f?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/0a0add59-b852-44a0-a3df-1c0eb8d4cd6f?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&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/4510)
Author
Owner

@sunderbharath85 commented on GitHub (Sep 10, 2025):

This is issue still exists. I have add dependency for 1.3.9 and tried to resolve, but it does not resolve.

<!-- gh-comment-id:3273734462 --> @sunderbharath85 commented on GitHub (Sep 10, 2025): This is issue still exists. I have add dependency for 1.3.9 and tried to resolve, but it does not resolve.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#18595