From 6dfd6805b17048531028febf95ad082ee6a045f2 Mon Sep 17 00:00:00 2001 From: Jaime Bernardo Date: Tue, 5 Dec 2023 14:41:04 +0000 Subject: [PATCH] Add support for nodejs-mobile --- lib/util/compile.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/util/compile.js b/lib/util/compile.js index c60455aad..6a2762370 100644 --- a/lib/util/compile.js +++ b/lib/util/compile.js @@ -10,6 +10,7 @@ const cp = require('child_process'); // try to build up the complete path to node-gyp /* priority: + - node-gyp on ENV:NODEJS_MOBILE_GYP - node-gyp on ENV:npm_config_node_gyp (https://github.com/npm/npm/pull/4887) - node-gyp on NODE_PATH - node-gyp inside npm on NODE_PATH (ignore on iojs) @@ -17,6 +18,17 @@ const cp = require('child_process'); */ function which_node_gyp() { let node_gyp_bin; + if (process.env.NODEJS_MOBILE_GYP) { + // nodejs-mobile was using npm_config_node_gyp, but that's currently being overwritten by npm 7+ + try { + node_gyp_bin = process.env.NODEJS_MOBILE_GYP; + if (existsSync(node_gyp_bin)) { + return node_gyp_bin; + } + } catch (err) { + // do nothing + } + } if (process.env.npm_config_node_gyp) { try { node_gyp_bin = process.env.npm_config_node_gyp;