Skip to content

Commit 21c0ef2

Browse files
authored
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.
1 parent db5385c commit 21c0ef2

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

bin/node-gyp.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,15 @@ function errorMessage () {
125125
log.error('cwd', process.cwd())
126126
log.error('node -v', process.version)
127127
log.error('node-gyp -v', 'v' + prog.package.version)
128+
129+
// print the npm package version
130+
for (const env of ['npm_package_name', 'npm_package_version']) {
131+
const value = process.env[env]
132+
if (value != null) {
133+
log.error(`$${env}`, value)
134+
}
135+
}
136+
128137
}
129138

130139
function issueMessage () {

0 commit comments

Comments
 (0)