diff --git a/lib/util/compile.js b/lib/util/compile.js index c60455aa..6a276237 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;