Bun.serve() complains: TypeError: Expected fetch() to be a function

moogmodularHOBBY

a month ago

$ NODE_ENV=production bun run src/index.tsx

Apr 14 13:20:48

41 | console.error(`Error serving static file ${path}:`, error)

Apr 14 13:20:48

42 | return new Response('Internal server error', { status: 500 })

Apr 14 13:20:48

43 | }

Apr 14 13:20:48

44 | }

Apr 14 13:20:48

45 |

Apr 14 13:20:48

46 | export const server = Bun.serve({

Apr 14 13:20:48

^

Apr 14 13:20:48

TypeError: Expected fetch() to be a function

Apr 14 13:20:48

at /app/apps/web/src/index.tsx:46:27

Apr 14 13:20:48

Apr 14 13:20:48

Bun v1.1.43 (Linux x64)

I have a React app served with bun but it crashes on start. The Bun version seems quite old.

Solved

1 Replies

moogmodularHOBBY

a month ago

Figured it out. Prior to 1.2.3 you need to provide a fetch() method.
https://bun.sh/docs/bundler/fullstack


Status changed to Solved brody about 1 month ago