修复 Windows 桌面版启动报错 Cannot find module '@swc/helpers/_/_interop_require_default'(issue #10)。
背景:v0.8.33 把「启动失败」从静默变为可见弹窗后,这位 Win11 用户重装看到了真实报错——问题从「点击没反应」推进到了「启动即报模块缺失」。
根因:桌面版打包的 Next.js standalone 服务用 pnpm 的符号链接结构指向 .pnpm 虚拟store;Windows 打包拷贝(robocopy)会跟随并解引用这些链接,把 next 拍平到顶层、与它的对等依赖(@swc/helpers、styled-jsx 等)脱钩,于是服务器一启动 require('@swc/helpers/...') 就 MODULE_NOT_FOUND。macOS 的拷贝保留符号链接,所以只在 Windows 复现。这是 Next.js + pnpm + standalone 在 Windows 上的已知通病(vercel/next.js#50803)。
修复:
.npmrc启用node-linker=hoisted,让node_modules成为无符号链接的扁平真实文件树;standalone 产物随之零符号链接,任何系统、任何拷贝方式都能忠实复制、对等依赖不再丢失(根因修复)。- 打包脚本适配扁平布局(better-sqlite3 Electron-ABI 重建路径)。
- afterPack 增加构建期依赖自检:拷贝后校验
@swc/helpers、styled-jsx可从next解析,不通过则中止打包——从此绝不再发出启动即崩的包。
验证:在 Mac 上以「解引用拷贝」模拟 Windows 的拷贝行为——修复前 @swc/helpers 复现 MODULE_NOT_FOUND,修复后解析成功;Electron 端到端冒烟 /api/project 返回 200(better-sqlite3 迁移正常)。
若更新后仍有问题,请把日志文件发到 issue #10 协助排查:%APPDATA%\ClipForge\logs\server.log
- macOS (Apple Silicon):下载
.dmg,未签名,首次打开右键「打开」绕过 Gatekeeper。 - Windows (x64):下载
ClipForge.Setup.0.8.34.exe安装。内置 ffmpeg / sqlite,无需安装 Node。⚠️ Windows 版为自动构建,已过打包依赖自检、但无真机实测;如遇问题请贴server.log,我会跟进。
Fixes the Windows desktop startup crash Cannot find module '@swc/helpers/_/_interop_require_default' (#10).
Background: after v0.8.33 turned the silent startup failure into a visible dialog, the reporter reinstalled and finally saw the real error — the issue moved from "clicked, nothing happens" to "crashes on startup with a missing module".
Root cause: the packaged Next.js standalone server uses pnpm's symlink layout into the .pnpm virtual store. On Windows the packaging copy (robocopy) follows and dereferences those links, flattening next to the top level and detaching it from its peer deps (@swc/helpers, styled-jsx, …), so the server crashes on the first require('@swc/helpers/...') with MODULE_NOT_FOUND. macOS copies preserve symlinks, so it only reproduced on Windows. This is a known Next.js + pnpm + standalone issue on Windows (vercel/next.js#50803).
Fix:
- Enable
node-linker=hoistedin.npmrcsonode_modulesbecomes a flat, symlink-free tree of real files; the standalone output then contains zero symlinks and copies faithfully on every OS with any copy method — peer deps can no longer be dropped (root-cause fix). - Adapt the bundle script to the flat layout (better-sqlite3 Electron-ABI rebuild path).
- Add a build-time guardrail in afterPack: verify
@swc/helpersandstyled-jsxresolve fromnextafter the copy, and abort the build otherwise — so a package that crashes on startup can never ship again.
Verification: on macOS, a dereferencing copy (mimicking the Windows copy) reproduced MODULE_NOT_FOUND before the fix and resolves cleanly after; an end-to-end Electron smoke returns 200 from /api/project (better-sqlite3 migration OK).
If it still fails after updating, please attach %APPDATA%\ClipForge\logs\server.log to issue #10.
- macOS (Apple Silicon): download the
.dmg. Unsigned — right-click → "Open" on first launch to bypass Gatekeeper. - Windows (x64): download
ClipForge.Setup.0.8.34.exe. FFmpeg / SQLite bundled, no Node install required.