Skip to content

node-pre-gyp build behavior and documentation discrepancy #902

@DrBearZay

Description

@DrBearZay

❓ Question: node-pre-gyp build behavior and documentation discrepancy

While working with node-pre-gyp, I noticed a potential discrepancy between:

  1. The README.md command list
  2. The inline code comments
  3. The actual behavior in source

📌 Context

In the code comments, it says "We map node-pre-gyp build to node-gyp configure build", but in practice, node-pre-gyp build does not trigger node-gyp configure — only node-pre-gyp rebuild does.

However, the README does not mention anything about whether configure is required before running build or rebuild, which could be confusing for users.

Here is the source code:

function build(gyp, argv, callback) {

  // Form up commands to pass to node-gyp:
  // We map `node-pre-gyp build` to `node-gyp configure build` so that we do not
  // trigger a clean and therefore do not pay the penalty of a full recompile
  if (argv.length && (argv.indexOf('rebuild') > -1)) {
    argv.shift(); // remove `rebuild`
    // here we map `node-pre-gyp rebuild` to `node-gyp rebuild` which internally means
    // "clean + configure + build" and triggers a full recompile
    compile.run_gyp(['clean'], {}, (err3) => {
      if (err3) return callback(err3);
      configure(gyp, argv, (err4) => {
        if (err4) return callback(err4);
        return do_build(gyp, argv, callback);
      });
    });
  } else {
    return do_build(gyp, argv, callback);
  }
}

🧩 My Questions

  1. Is this behavior intentional?
  2. Would it be possible to:
  • update the README to explicitly mention the need for configure before build?
  • clarify the inline comment in build.js to avoid confusion?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions