Skip to content

fix: 降级 ink/react 使 Node >=18 兼容声明真实成立 - #10

Merged
liuziyuan merged 1 commit into
mainfrom
fix/node18-compat
Sep 7, 2026
Merged

fix: 降级 ink/react 使 Node >=18 兼容声明真实成立#10
liuziyuan merged 1 commit into
mainfrom
fix/node18-compat

Conversation

@liuziyuan

Copy link
Copy Markdown
Owner

背景

package.json 声明 engines.node: ">=18",但运行时依赖 ink ^6.8.0 要求 node >=20——Node 18 用户安装时 npm 仅警告,实际运行会失败,声明形同虚设。

改动

依赖 之前 之后 原因
ink ^6.8.0 ^5.2.1 ink 6.x engines 为 >=20;ink 5.2.1 为 >=18
react ^19.0.0 ^18.3.1 ink 5 的 reconciler 依赖 React 18 内部 API
@types/react ^19 ^18 与 react 18 对应

为什么 react 必须一起降

ink 5.2.1 的 peerDependencies 写的是 react >=18.0.0,但只单独降 ink 时实测启动即崩:

TypeError: Cannot read properties of undefined (reading 'ReactCurrentOwner')

react 19 移除了 ink 5 所依赖的 __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED 内部结构,>=18.0.0 这个 peer 范围写得过宽。代码仅使用 import React 等稳定 API,18/19 无差异,降级零代码改动。

验证

  • npx tsc --noEmit 通过
  • npm run build 通过
  • pty 实测 TUI 完整渲染:session 列表、▲/▼ N more 分页提示、底部快捷键栏均正常,无任何错误(单独降 ink 时崩溃,ink 5 + react 18 组合 0 错误)
  • npm audit --audit-level=high 通过(仅 1 low)
  • 版本 1.7.0 → 1.7.1(fix → patch),lock 已同步

🤖 Generated with Claude Code

ink ^6.8.0 声明 engines node >=20,与 package.json 的 >=18 冲突,
Node 18 用户实际无法运行。降级到 ink 5.2.1(engines >=18)。

同时降级 react 19 → 18.3.1:ink 5 的 reconciler 依赖 React 18
内部 API,搭配 react 19 实测启动即崩(TypeError: Cannot read
properties of undefined (reading 'ReactCurrentOwner')),
@types/react 同步降至 ^18。

实测:pty 中 TUI 完整渲染(列表/分页/快捷键栏)无任何错误;
tsc --noEmit、npm run build、npm audit --audit-level=high 全部通过。

版本 1.7.0 → 1.7.1(fix → patch)。

Co-Authored-By: Claude Code <noreply@anthropic.com>
@liuziyuan
liuziyuan merged commit d2afce9 into main Sep 7, 2026
1 check passed
@liuziyuan
liuziyuan deleted the fix/node18-compat branch September 7, 2026 06:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant