Bun build error: Unexpected "super" in better-call #1737

Closed
opened 2026-03-13 08:59:44 -05:00 by GiteaMirror · 27 comments
Owner

Originally created by @SohelIslamImran on GitHub (Aug 19, 2025).

Bun build failed

: $ bun build server.ts --outfile ./dist/server --target bun --minify-whitespace --minify-syntax --sourcemap --compile
 43 |         super(...args);
             ^
 error: Unexpected "super"
     at /kuno-backend/node_modules/better-call/dist/index.js:43:9

Maybe something wrong in node_modules/better-call/dist/index.js:43:9

Image
Originally created by @SohelIslamImran on GitHub (Aug 19, 2025). Bun build failed ```bash : $ bun build server.ts --outfile ./dist/server --target bun --minify-whitespace --minify-syntax --sourcemap --compile 43 | super(...args); ^ error: Unexpected "super" at /kuno-backend/node_modules/better-call/dist/index.js:43:9 ``` Maybe something wrong in node_modules/better-call/dist/index.js:43:9 <img width="786" height="520" alt="Image" src="https://github.com/user-attachments/assets/89453c81-8781-4a54-828f-b3c1cdd2bb8b" />
GiteaMirror added the javascript label 2026-03-13 08:59:44 -05:00
Author
Owner

@fredericbahr commented on GitHub (Aug 19, 2025):

Also happens in Node envs

@fredericbahr commented on GitHub (Aug 19, 2025): Also happens in Node envs
Author
Owner

@dosubot[bot] commented on GitHub (Aug 19, 2025):

This error happens because better-call is distributed with ES6+ syntax (like class and super), but Bun expects input files to be transpiled to ES5/CommonJS unless configured otherwise. If Bun encounters ES6+ features in dependencies, it can throw parsing errors like "Unexpected 'super'" see details.

To work around this, you can try one of these approaches: transpile better-call to ES5 yourself before building, configure Bun (if possible) to accept ES6+ modules as input, or use a Node.js-based build process instead. There’s currently no official ES5 build or Bun compatibility layer for better-call or better-auth.

To reply, just mention @dosu.


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

@dosubot[bot] commented on GitHub (Aug 19, 2025): <!-- Answer --> This error happens because better-call is distributed with ES6+ syntax (like class and super), but Bun expects input files to be transpiled to ES5/CommonJS unless configured otherwise. If Bun encounters ES6+ features in dependencies, it can throw parsing errors like "Unexpected 'super'" [see details](https://github.com/better-auth/better-auth/issues/3568). To work around this, you can try one of these approaches: transpile better-call to ES5 yourself before building, configure Bun (if possible) to accept ES6+ modules as input, or use a Node.js-based build process instead. There’s currently no official ES5 build or Bun compatibility layer for better-call or better-auth. <!-- 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/936e7464-11af-4e66-a3e2-80bc7bac36a7?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/936e7464-11af-4e66-a3e2-80bc7bac36a7?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/936e7464-11af-4e66-a3e2-80bc7bac36a7?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/936e7464-11af-4e66-a3e2-80bc7bac36a7?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/936e7464-11af-4e66-a3e2-80bc7bac36a7?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/936e7464-11af-4e66-a3e2-80bc7bac36a7?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/936e7464-11af-4e66-a3e2-80bc7bac36a7?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/4082)
Author
Owner

@SohelIslamImran commented on GitHub (Aug 19, 2025):

Any workaround?

@SohelIslamImran commented on GitHub (Aug 19, 2025): Any workaround?
Author
Owner

@zpg6 commented on GitHub (Aug 19, 2025):

To prevent this in the future.. perhaps better-call, better-fetch, and other dependencies in the ecosystem should be pinned to stable versions, and their new releases evaluated in better-auth beta releases.

@zpg6 commented on GitHub (Aug 19, 2025): To prevent this in the future.. perhaps `better-call`, `better-fetch`, and other dependencies in the ecosystem should be pinned to stable versions, and their new releases evaluated in better-auth beta releases.
Author
Owner

@SamuelMabonga commented on GitHub (Aug 19, 2025):

is there a work around that I could use...I've lost my production server to this

@SamuelMabonga commented on GitHub (Aug 19, 2025): is there a work around that I could use...I've lost my production server to this
Author
Owner

@AbhishekMandilkar commented on GitHub (Aug 19, 2025):

This issue also occurs for pnpm as well

@AbhishekMandilkar commented on GitHub (Aug 19, 2025): This issue also occurs for `pnpm` as well
Author
Owner

@zpg6 commented on GitHub (Aug 19, 2025):

@SohelIslamImran @SamuelMabonga

Seems to have been patched, my issue was closed
https://github.com/Bekacru/better-call/pull/39

@zpg6 commented on GitHub (Aug 19, 2025): @SohelIslamImran @SamuelMabonga Seems to have been patched, my issue was closed https://github.com/Bekacru/better-call/pull/39
Author
Owner

@nicognaW commented on GitHub (Aug 19, 2025):

looks like it's an upstream issue in better-call, and the fix has already been merged in https://github.com/Bekacru/better-call/pull/39 , lets wait for the release

@nicognaW commented on GitHub (Aug 19, 2025): looks like it's an upstream issue in better-call, and the fix has already been merged in https://github.com/Bekacru/better-call/pull/39 , lets wait for the release
Author
Owner

@kamikazechaser commented on GitHub (Aug 19, 2025):

Still seems broken on bun, even after installing the patched better-call version (v1.0.15-beta.1).

cc/ @himself65

@kamikazechaser commented on GitHub (Aug 19, 2025): Still seems broken on bun, even after installing the patched better-call version (v1.0.15-beta.1). cc/ @himself65
Author
Owner

@himself65 commented on GitHub (Aug 19, 2025):

Thanks mention. I didn't think about the bundler targeting the old JS version.

Fixed in better-call 1.0.15-beta.1

@himself65 commented on GitHub (Aug 19, 2025): Thanks mention. I didn't think about the bundler targeting the old JS version. Fixed in better-call 1.0.15-beta.1
Author
Owner

@kamikazechaser commented on GitHub (Aug 19, 2025):

@himself65

Fixed in better-call 1.0.15-beta.1

Could you confirm if this fixes it for bun.

@kamikazechaser commented on GitHub (Aug 19, 2025): @himself65 > Fixed in better-call 1.0.15-beta.1 Could you confirm if this fixes it for bun.
Author
Owner

@SohelIslamImran commented on GitHub (Aug 19, 2025):

Thanks mention. I didn't think about the bundler targeting the old JS version.

Fixed in better-call 1.0.15-beta.1

But we are using better-auth, not better-call, and it still installs the ^1.0.14 @himself65

@SohelIslamImran commented on GitHub (Aug 19, 2025): > Thanks mention. I didn't think about the bundler targeting the old JS version. > > Fixed in better-call 1.0.15-beta.1 But we are using better-auth, not better-call, and it still installs the ^1.0.14 @himself65
Author
Owner

@nicognaW commented on GitHub (Aug 19, 2025):

Image

guys, i just tested better-call 1.0.15-beta.1 and it works, add this to your package.json:

  "overrides": {
    "better-call": "1.0.15-beta.1"
  }
@nicognaW commented on GitHub (Aug 19, 2025): <img width="427" height="45" alt="Image" src="https://github.com/user-attachments/assets/e5081aa0-e093-455e-b502-1b04b40a544b" /> guys, i just tested better-call 1.0.15-beta.1 and it works, add this to your package.json: ``` "overrides": { "better-call": "1.0.15-beta.1" } ```
Author
Owner

@himself65 commented on GitHub (Aug 19, 2025):

Image guys, i just tested better-call 1.0.15-beta.1 and it works, add this to your package.json:
  "overrides": {
    "better-call": "1.0.15-beta.1"
  }

Yeah, you can use 1.0.13 also.

I think it's from package.json says ^1.0.13, so it will download 1.0.14 for the new installation

@himself65 commented on GitHub (Aug 19, 2025): > <img alt="Image" width="427" height="45" src="https://private-user-images.githubusercontent.com/66731869/479651512-e5081aa0-e093-455e-b502-1b04b40a544b.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NTU2MjY4OTYsIm5iZiI6MTc1NTYyNjU5NiwicGF0aCI6Ii82NjczMTg2OS80Nzk2NTE1MTItZTUwODFhYTAtZTA5My00NTVlLWI1MDItMWIwNGI0MGE1NDRiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTA4MTklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwODE5VDE4MDMxNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWZkZjQ0ZDNkNmYzZjQ0ZDUyN2I4ZGJjOGU1NmE4NWMyNTAwNTY5ZmI5N2RlOWQzZTAyZGM0YWFjZTk5YzRjZTUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.M-bVOE3MFFR36sX-RVpSyC6rsir4lGOhamdpHJO7upw"> > guys, i just tested better-call 1.0.15-beta.1 and it works, add this to your package.json: > > ``` > "overrides": { > "better-call": "1.0.15-beta.1" > } > ``` Yeah, you can use 1.0.13 also. I think it's from package.json says `^1.0.13`, so it will download 1.0.14 for the new installation
Author
Owner

@himself65 commented on GitHub (Aug 19, 2025):

1.0.15 is released. Please reinstall the package, it should work

@himself65 commented on GitHub (Aug 19, 2025): [1.0.15](https://www.npmjs.com/package/better-call/v/1.0.15) is released. Please reinstall the package, it should work
Author
Owner

@zpg6 commented on GitHub (Aug 19, 2025):

Quick fix.. appreciate yall

@zpg6 commented on GitHub (Aug 19, 2025): Quick fix.. appreciate yall
Author
Owner

@zpg6 commented on GitHub (Aug 19, 2025):

To prevent this in the future.. perhaps better-call, better-fetch, and other dependencies in the ecosystem should be pinned to stable versions, and their new releases evaluated in better-auth beta releases.

https://github.com/better-auth/better-auth-ecosystem-ci - Nice!

@zpg6 commented on GitHub (Aug 19, 2025): > To prevent this in the future.. perhaps `better-call`, `better-fetch`, and other dependencies in the ecosystem should be pinned to stable versions, and their new releases evaluated in better-auth beta releases. https://github.com/better-auth/better-auth-ecosystem-ci - Nice!
Author
Owner

@himself65 commented on GitHub (Aug 19, 2025):

yeah, i'm setting things up https://github.com/better-auth/better-auth-ecosystem-ci

@himself65 commented on GitHub (Aug 19, 2025): yeah, i'm setting things up https://github.com/better-auth/better-auth-ecosystem-ci
Author
Owner

@khalilelghoul01 commented on GitHub (Aug 19, 2025):

and how to fix it for better-auth as i have the latest version but keep having the same problem and it caused a production app to fail

@khalilelghoul01 commented on GitHub (Aug 19, 2025): and how to fix it for better-auth as i have the latest version but keep having the same problem and it caused a production app to fail
Author
Owner

@nicognaW commented on GitHub (Aug 19, 2025):

and how to fix it for better-auth as i have the latest version but keep having the same problem and it caused a production app to fail

try bun pm cache rm and bunx @better-auth/cli@1.3.4 ... if you're using bun,due to https://github.com/better-auth/better-auth/issues/3951, versions after 1.3.4 still don't work on bun

@nicognaW commented on GitHub (Aug 19, 2025): > and how to fix it for better-auth as i have the latest version but keep having the same problem and it caused a production app to fail try `bun pm cache rm` and `bunx @better-auth/cli@1.3.4 ...` if you're using bun,due to https://github.com/better-auth/better-auth/issues/3951, versions after 1.3.4 still don't work on bun
Author
Owner

@himself65 commented on GitHub (Aug 19, 2025):

and how to fix it for better-auth as i have the latest version but keep having the same problem and it caused a production app to fail

You might need to check your lockfile to see which version of the better-call are you using

@himself65 commented on GitHub (Aug 19, 2025): > and how to fix it for better-auth as i have the latest version but keep having the same problem and it caused a production app to fail You might need to check your lockfile to see which version of the better-call are you using
Author
Owner

@khalilelghoul01 commented on GitHub (Aug 19, 2025):

 "node_modules/better-auth": {
      "version": "1.3.7",
      "resolved": "https://registry.npmjs.org/better-auth/-/better-auth-1.3.7.tgz",
      "integrity": "sha512-/1fEyx2SGgJQM5ujozDCh9eJksnVkNU/J7Fk/tG5Y390l8nKbrPvqiFlCjlMM+scR+UABJbQzA6An7HT50LHyQ==",
      "license": "MIT",
      "dependencies": {
        "@better-auth/utils": "0.2.6",
        "@better-fetch/fetch": "^1.1.18",
        "@noble/ciphers": "^0.6.0",
        "@noble/hashes": "^1.8.0",
        "@simplewebauthn/browser": "^13.1.2",
        "@simplewebauthn/server": "^13.1.2",
        "better-call": "^1.0.13",
        "defu": "^6.1.4",
        "jose": "^5.10.0",
        "kysely": "^0.28.5",
        "nanostores": "^0.11.4"
      },

it is using this version "better-call": "^1.0.13",

@khalilelghoul01 commented on GitHub (Aug 19, 2025): ```json "node_modules/better-auth": { "version": "1.3.7", "resolved": "https://registry.npmjs.org/better-auth/-/better-auth-1.3.7.tgz", "integrity": "sha512-/1fEyx2SGgJQM5ujozDCh9eJksnVkNU/J7Fk/tG5Y390l8nKbrPvqiFlCjlMM+scR+UABJbQzA6An7HT50LHyQ==", "license": "MIT", "dependencies": { "@better-auth/utils": "0.2.6", "@better-fetch/fetch": "^1.1.18", "@noble/ciphers": "^0.6.0", "@noble/hashes": "^1.8.0", "@simplewebauthn/browser": "^13.1.2", "@simplewebauthn/server": "^13.1.2", "better-call": "^1.0.13", "defu": "^6.1.4", "jose": "^5.10.0", "kysely": "^0.28.5", "nanostores": "^0.11.4" }, ``` it is using this version "better-call": "^1.0.13",
Author
Owner

@himself65 commented on GitHub (Aug 19, 2025):

^1.0.13 will resolve to 1.0.15, it's under ^

Image

Not sure how to use Bun, but I would guess bun update better-auth? or just delete lock file and reinstall

@himself65 commented on GitHub (Aug 19, 2025): ^1.0.13 will resolve to 1.0.15, it's under `^` <img width="1047" height="565" alt="Image" src="https://github.com/user-attachments/assets/1c4f0011-0b93-4155-b14b-01ca15abfcac" /> Not sure how to use Bun, but I would guess `bun update better-auth`? or just delete lock file and reinstall
Author
Owner

@khalilelghoul01 commented on GitHub (Aug 19, 2025):

i'll try it

@khalilelghoul01 commented on GitHub (Aug 19, 2025): i'll try it
Author
Owner

@khalilelghoul01 commented on GitHub (Aug 19, 2025):

The solution was to add the following overrides to my package.json file. This forces better-call to v1.0.15 and updates the lockfile accordingly.

 "overrides": {
    "better-call": "1.0.15"
  }

This is a temporary fix until better-auth is released with the updated better-call dependency.

@khalilelghoul01 commented on GitHub (Aug 19, 2025): The solution was to add the following overrides to my package.json file. This forces better-call to v1.0.15 and updates the lockfile accordingly. ```json "overrides": { "better-call": "1.0.15" } ``` This is a temporary fix until better-auth is released with the updated better-call dependency.
Author
Owner

@Boston343 commented on GitHub (Aug 29, 2025):

None of these solutions worked for me in a vite project (Astro project) unfortunately. I looked at the actual js being used on the client and it was different than the better-auth_api.js implementation. Realized vite optimizations might be to blame. Updating the vite config works for me:

vite: {
  optimizeDeps: {
    exclude: ["better-auth"],
  },
},
@Boston343 commented on GitHub (Aug 29, 2025): None of these solutions worked for me in a vite project (Astro project) unfortunately. I looked at the actual js being used on the client and it was different than the better-auth_api.js implementation. Realized vite optimizations might be to blame. Updating the vite config works for me: ```ts vite: { optimizeDeps: { exclude: ["better-auth"], }, }, ```
Author
Owner

@Jahan-Shah commented on GitHub (Aug 31, 2025):

@Boston343 Thanks this worked for me as well. I'm using react with vite.

@Jahan-Shah commented on GitHub (Aug 31, 2025): @Boston343 Thanks this worked for me as well. I'm using react with vite.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#1737