[bug] node-gyp configure.js within Prebuild tries overwriting cflags read only properties.
Clearmist opened this issue · comments
Matthew Sanders commented
Hello! I am trying to build prebuilt binaries. I've come up against this block and would like to know if there's something simple I'm missing.
prebuild: latest
node: 20.3.1
When running prebuild --runtime napi --all --strip --verbose
the following error is reported.
D:\test\node_modules\prebuild\node_modules\node-gyp\lib\configure.js:118
defaults.cflags = []
^
TypeError: Cannot assign to read only property 'cflags' of object '#<Object>'
at createConfigFile (D:\test\node_modules\prebuild\node_modules\node-gyp\lib\configure.js:118:21)
at process.processTicksAndRejections (node:internal/process/task_queues:77:11)
Node.js v20.3.
The source file configure.js
includes this code:
// don't inherit the "defaults" from node's `process.config` object.
// doing so could cause problems in cases where the `node` executable was
// compiled on a different machine (with different lib/include paths) than
// the machine where the addon is being built to
defaults.cflags = []
defaults.defines = []
defaults.include_dirs = []
defaults.libraries = []
The properties it is overwriting come from the ProcessConfig
interface located here: %Users%/AppData/Microsoft/Typescript/5.1/node_modules/@types/node/process.d.ts
.
declare module 'process' {
import * as tty from 'node:tty';
import { Worker } from 'node:worker_threads';
global {
var process: NodeJS.Process;
namespace NodeJS {
interface ProcessConfig {
readonly target_defaults: {
readonly cflags: any[];
readonly default_configuration: string;
readonly defines: string[];
readonly include_dirs: string[];
readonly libraries: string[];
};
...
Sibelius Seraphini commented
can we upgrade to latest node-gyp ?
Lovell Fuller commented
prebuild v12.0.0 upgrades node-gyp for Node.js 20 support.