From 76fc45466059ea8c7d599164b4193298f5810166 Mon Sep 17 00:00:00 2001 From: Caleb Everett Date: Mon, 15 Dec 2025 15:55:45 -0800 Subject: [PATCH] feat: include built package version in error logs I'm working on upgrading a lot of packages to node 24 and there are many failures in native modules. Looking at logs alone it's hard to spot which package versions are failing to build. node-gyp prints debug info about node, npm, and node-gyp but not the package that is currently being built. It doesn't look like node-gyp reads package.json so I opted to read npm_package_ env vars, which is similar to the npm_config_ env vars node-gyp already reads. --- bin/node-gyp.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bin/node-gyp.js b/bin/node-gyp.js index f8317b47b3..5393a5c8e1 100755 --- a/bin/node-gyp.js +++ b/bin/node-gyp.js @@ -125,6 +125,13 @@ function errorMessage () { log.error('cwd', process.cwd()) log.error('node -v', process.version) log.error('node-gyp -v', 'v' + prog.package.version) + // print the npm package version + for (const env of ['npm_package_name', 'npm_package_version']) { + const value = process.env[env] + if (value != null) { + log.error(`$${env}`, value) + } + } } function issueMessage () {