You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Bun+Express运行Remix生产服务器时出现jsxDEV未定义错误

问题描述

我用Bun和Express运行Remix生产服务器,开发环境正常,但构建后访问时出现以下错误:

$ NODE_ENV=production bun run src/index.ts
[12:00:19.443] INFO (83887): API listening on port 8080
62 |   let controller = new AbortController(), rendered = !1;
63 |   setTimeout(() => {
64 |     rendered || controller.abort();
65 |   }, ABORT_DELAY);
66 |   let stream = await renderToReadableStream(
67 |     /* @__PURE__ */ jsxDEV(
                         ^
TypeError: undefined is not a function (near '...jsxDEV...')
      at /Users/dangoodman/code/sellmyai/build/index.js:67:21
      at handleBrowserRequest (/Users/dangoodman/code/sellmyai/build/index.js:61:37)
      at /Users/dangoodman/code/sellmyai/node_modules/@remix-run/server-runtime/dist/server.js:224:18
      at processTicksAndRejections (:61:77)

62 |   let controller = new AbortController(), rendered = !1;
63 |   setTimeout(() => {
64 |     rendered || controller.abort();
65 |   }, ABORT_DELAY);
66 |   let stream = await renderToReadableStream(
67 |     /* @__PURE__ */ jsxDEV(
                         ^
TypeError: undefined is not a function (near '...jsxDEV...')
      at /Users/dangoodman/code/sellmyai/build/index.js:67:21
      at handleBrowserRequest (/Users/dangoodman/code/sellmyai/build/index.js:61:37)
      at /Users/dangoodman/code/sellmyai/node_modules/@remix-run/server-runtime/dist/server.js:251:20
      at processTicksAndRejections (:61:77)

[12:00:22.963] DEBUG (83887): loaded URL
    URL: "http://localhost:8080/"

entry.server.tsx完全使用Remix官方Express模板,且仅在本地macOS x64环境出现问题,Docker构建运行正常。

解决方案
  • 升级Bun版本:本地macOS的Bun版本可能与Docker环境不一致,执行bun upgrade更新到最新稳定版。
  • 清理构建缓存:删除本地build目录和node_modules,重新安装依赖并构建:
    rm -rf build node_modules
    bun install
    NODE_ENV=production bun run build
    
  • 配置Bun的JSX编译模式:在项目根目录的bunfig.toml中添加生产环境JSX配置:
    [jsx]
    mode = "production"
    
  • 确认Remix构建配置:检查remix.config.js,确保生产构建时mode参数设为production,避免开发模式的JSX转换产物被带入生产环境。

内容的提问来源于stack exchange,提问作者danthegoodman

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.02 13:23:19