From fa14e39633c52be12cf0a5166b59b7ccf523257c Mon Sep 17 00:00:00 2001 From: Evan Job Date: Sat, 17 Oct 2026 15:17:04 -0400 Subject: [PATCH] fix: load the addon without the undeclared @mapbox/node-pre-gyp; build with C++20 for Node 24 (#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 #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 --- binding.gyp | 6 +++--- lib/printer-binding.js | 11 ++++++++--- package.json | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/binding.gyp b/binding.gyp index d84b1747..59729d48 100644 --- a/binding.gyp +++ b/binding.gyp @@ -66,7 +66,7 @@ ], "msvs_settings": { "VCCLCompilerTool": { - "AdditionalOptions": [ "-std:c++17", ], + "AdditionalOptions": [ "-std:c++20", ], }, }, }], @@ -75,14 +75,14 @@ "-stdlib=libc++" ], 'xcode_settings': { - "OTHER_CPLUSPLUSFLAGS":["-std=c++17", "-stdlib=libc++"], + "OTHER_CPLUSPLUSFLAGS":["-std=c++20", "-stdlib=libc++"], "OTHER_LDFLAGS": ["-stdlib=libc++"], "MACOSX_DEPLOYMENT_TARGET": "14.0", }, }], ['OS=="linux"', { 'cflags_cc':[ - "-std=c++17" + "-std=c++20" ] }], ] diff --git a/lib/printer-binding.js b/lib/printer-binding.js index 337dc1cf..219441b4 100644 --- a/lib/printer-binding.js +++ b/lib/printer-binding.js @@ -1,6 +1,11 @@ const path = require('path'); -const binary = require('@mapbox/node-pre-gyp'); -const binding_path = binary.find(path.resolve(path.join(__dirname, '../package.json'))); -const binding = require(binding_path); + +let binding; +try { + binding = require(path.join(__dirname, 'node_printer.node')); +} catch (err) { + if (err.code !== 'MODULE_NOT_FOUND') throw err; + binding = require(path.join(__dirname, '..', 'build', 'Release', 'node_printer.node')); +} module.exports = exports = binding; diff --git a/package.json b/package.json index d321f739..92d23f36 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "patch-package": "^8.0.0" }, "dependencies": { - "nan": "^2.19.0", + "nan": "^2.28.0", "prebuild-install": "^7.1.2" } }