Skip to content

fix: load the addon without the undeclared @mapbox/node-pre-gyp; build with C++20 for Node 24 (#11) - #13

Open
evanjob2005-ux wants to merge 1 commit into
grandchef:mainfrom
evanjob2005-ux:node24-cxx20-loader
Open

evanjob2005-ux wants to merge 1 commit into
grandchef:mainfrom
evanjob2005-ux:node24-cxx20-loader

Conversation

@evanjob2005-ux

Copy link
Copy Markdown

Summary

Two problems, both reproduced in clean Linux containers (Debian, libcups2-dev installed):

  1. require('@grandchef/node-printer') crashes on every Node version. lib/printer-binding.js requires
    @mapbox/node-pre-gyp, which is not a dependency (not in package.json, not in the published 0.8.0). A clean
    npm install @grandchef/node-printer@0.8.0 on Node 20 installs fine and then fails at require() with
    Cannot find module '@mapbox/node-pre-gyp'.
    Fix: load the compiled addon directly -- lib/node_printer.node (where binding.gyp's action_after_build copies
    it and where prebuild-install places a downloaded binary), falling back to build/Release/node_printer.node only
    when that file is missing. Any other load error (e.g. an ABI mismatch) is rethrown, not hidden.
  2. Building from source fails on Node 24 with #error "C++20 or later required." from the Node headers, because
    binding.gyp pins -std=c++17 on Linux, macOS and Windows. Raised to C++20 on all three, and nan to ^2.28.0
    (the V8 13 API changes noted in Build fails on Electron 42+/V8 13 (nan + C++20) #11).

No new dependencies. Fixes #11.

How it was checked

In Docker (node:20, node:22, node:24 + libcups2-dev), each check run twice per version:

  • Install + load: npm install in the repo, then require('./') exports getPrinters -- passed 2/2 on Node 20,
    22 and 24. On Node 24 the addon was compiled from source (no prebuilt binary exists for that ABI), which is the
    C++20 change being exercised; on Node 20/22 prebuild-install supplied the existing prebuilt binary.
  • Consumer install: npm pack, install the tarball into a fresh project, require('@grandchef/node-printer')
    exports getPrinters -- passed 2/2 on Node 20, 22 and 24.
  • Before the change, the same Node 24 build failed at install, and the published 0.8.0 failed at require().

Not tested here: macOS and Windows builds (the same C++20 flag change was tested on darwin arm64 in #12), and actual
printing (no CUPS daemon in the container) -- the checks cover install, build, load and the exported API.

🤖 Generated with Claude Code

…d with C++20 for Node 24 (grandchef#11)

lib/printer-binding.js required @mapbox/node-pre-gyp, which is not a dependency (not in package.json, not in the
published 0.8.0), so require('@grandchef/node-printer') failed with "Cannot find module '@mapbox/node-pre-gyp'" on every
Node version. It now loads lib/node_printer.node (the copy binding.gyp's action_after_build makes, and where
prebuild-install places a downloaded binary), falling back to build/Release/node_printer.node only when that file is
missing; any other load error (e.g. an ABI mismatch) is rethrown.

binding.gyp pinned -std=c++17 on Linux, macOS and Windows; the Node 24 headers require C++20
("#error C++20 or later required"). Raised to C++20 on all three, and nan to ^2.28.0 for the V8 13 API changes in grandchef#11.

No new dependencies.

Consulted: 2026-10-17T18-47-58-503Z-orchestration-19204.json
Reviewed-by: none (repair on a fork; graded by the upgrade pipeline: smoke + consumer-install twice each on Node 20/22/24, VERIFIED_REPAIR)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

Build fails on Electron 42+/V8 13 (nan + C++20)

1 participant