Skip to content

fix: support Node v24+ with native-keymap C++20 patch and automated postinstall - #4211

Merged
Jocs merged 2 commits into
developfrom
worktree-harmonic-juggling-lark
May 15, 2026
Merged

Jocs merged 2 commits into
developfrom
worktree-harmonic-juggling-lark

Conversation

@Jocs

@Jocs Jocs commented May 15, 2026

Copy link
Copy Markdown
Member

Summary

  • Root cause: Node v24+ (including v26) requires C++20 in V8 headers, but [email protected]'s binding.gyp doesn't declare it, causing ~20 compiler errors. Additionally, Electron v42+ no longer ships an install script, so the binary isn't downloaded during npm install.
  • Fix: Automated postinstall hook handles everything — npm install && npm run dev now works out of the box on any supported Node version.

Changes

File Change
patches/native-keymap+3.3.9.patch Adds C++20 compiler flags for macOS (CLANG_CXX_LANGUAGE_STANDARD), Linux (cflags_cc), and Windows (LanguageStandard)
package.json Adds postinstall script; adds patch-package to devDependencies; bumps electron to ^42.1.0
SETUP.md Documents setup process, mirror configuration for slow networks, and troubleshooting

postinstall flow

npm install
  └→ postinstall (runs automatically):
      1. node node_modules/electron/install.js   # download Electron binary
      2. patch-package                            # apply C++20 fix to native-keymap
      3. npx @electron/rebuild -f                 # recompile native modules for Electron ABI
      4. npm run minify-locales                   # generate .min.json translation files

Test plan

  • Fresh clone on Node v26: npm install && npm run dev — app opens without errors
  • Fresh clone on Node v20/v22 LTS: same command works
  • Verify patches/native-keymap+3.3.9.patch applies cleanly via patch-package
  • Verify no translation errors at startup

🤖 Generated with Claude Code

… postinstall

Node v24+ requires C++20 in V8 headers, but [email protected]'s binding.gyp
doesn't declare it, causing ~20 compiler errors. Also, Electron v42+ no longer
ships an install script, so the binary must be downloaded explicitly.

- Add patches/native-keymap+3.3.9.patch: adds C++20 flags for macOS, Linux, Windows
- Add postinstall script to package.json that runs automatically after npm install:
  1. Downloads Electron binary (node_modules/electron/install.js)
  2. Applies the C++20 patch via patch-package
  3. Rebuilds native modules for Electron's ABI via @electron/rebuild
  4. Generates minified translation files via minify-locales
- Add patch-package to devDependencies
- Bump electron to ^42.1.0
- Add SETUP.md documenting the setup process and mirror configuration

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Copilot AI review requested due to automatic review settings May 15, 2026 06:52
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to make the development install experience work on newer Node/Electron versions by automatically downloading Electron, applying a native-keymap C++20 build patch, rebuilding native modules, and generating minified locale files during npm install.

Changes:

  • Added a postinstall hook to run Electron download, apply patch-package, rebuild native modules, and minify locales automatically.
  • Introduced a patch-package patch to force C++20 for [email protected] across macOS/Linux/Windows.
  • Added a new SETUP.md with quickstart, mirror configuration, and troubleshooting guidance.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.

File Description
SETUP.md New developer setup guide describing the new automated postinstall flow and troubleshooting.
patches/native-keymap+3.3.9.patch Patch-package diff to add C++20 compilation settings to native-keymap’s binding.gyp.
package.json Adds postinstall, adds patch-package, and bumps Electron to ^42.1.0.
package-lock.json Lockfile updates for Electron bump and new patch-package dependency tree.
Comments suppressed due to low confidence (1)

package.json:37

  • The postinstall script inlines multiple steps, including a rebuild command that’s already defined as rebuild-native. Consider delegating to existing npm scripts (e.g. npm run rebuild-native and npm run minify-locales) to avoid duplication and keep flags/behavior consistent if these steps need to change later.
  "scripts": {
    "postinstall": "node node_modules/electron/install.js && patch-package && npx @electron/rebuild -f && npm run minify-locales",
    "format": "prettier --write .",
    "lint": "eslint --cache .",
    "minify-locales": "node scripts/minify-locales.mjs",
    "rebuild-native": "npx @electron/rebuild -f",

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread package.json Resolved
@Jocs
Jocs merged commit 2db0ff4 into develop May 15, 2026
@Jocs
Jocs deleted the worktree-harmonic-juggling-lark branch May 16, 2026 05:56
@Jocs Jocs mentioned this pull request May 18, 2026
thimbleberrysystems pushed a commit to thimbleberrysystems/WordBird that referenced this pull request Jun 21, 2026
…ostinstall (marktext#4211)

* fix: support Node v24+ by patching native-keymap C++20 and automating postinstall

Node v24+ requires C++20 in V8 headers, but [email protected]'s binding.gyp
doesn't declare it, causing ~20 compiler errors. Also, Electron v42+ no longer
ships an install script, so the binary must be downloaded explicitly.

- Add patches/native-keymap+3.3.9.patch: adds C++20 flags for macOS, Linux, Windows
- Add postinstall script to package.json that runs automatically after npm install:
  1. Downloads Electron binary (node_modules/electron/install.js)
  2. Applies the C++20 patch via patch-package
  3. Rebuilds native modules for Electron's ABI via @electron/rebuild
  4. Generates minified translation files via minify-locales
- Add patch-package to devDependencies
- Bump electron to ^42.1.0
- Add SETUP.md documenting the setup process and mirror configuration

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* chore: remove SETUP.md

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

---------

Co-authored-by: Claude Sonnet 4.6 <[email protected]>
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.

2 participants