node-gyp-build is a critical utility for Node.js native addon developers, streamlining the distribution and loading of C/C++ bindings. It acts as both an `npm install` script and a runtime loader, prioritizing the use of precompiled binaries (prebuilds) over source compilation. Currently at stable version 5.2.2, its release cadence is typically tied to major Node.js ABI changes or significant updates in the native module tooling ecosystem. Its key differentiator is its seamless integration with `prebuildify` to provide robust cross-platform support, including different Node.js versions, Electron environments, and various architectures (e.g., `musl` for Alpine Linux, specific ARM versions). This significantly reduces installation friction for end-users, who often lack the necessary C++ toolchains. It intelligently detects runtime specifics like `libc` and `armv` to load the most appropriate prebuild, with options for users to override and force source compilation via `npm install --build-from-source`.
npm install node-gyp-build-optional-packagesVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to configure `node-gyp-build` as an `npm install` script and use it to load a native module's binding at runtime, favoring prebuilds.
Ensure `prebuildify` is also updated to a compatible version (e.g., `prebuildify@3` or newer) and regenerate your prebuilds.
For developers, ensure your `binding.gyp` file is correctly configured and `node-gyp`'s prerequisites (Python, C++ build tools) are available for users who choose this option. For users, ensure your system has the necessary build tools.
Always pass the root directory of your native module (`__dirname`) or the explicit path to your `build/Release` folder (e.g., `path.join(__dirname, 'build/Release')`) to the `loadBinding` function.
Ensure you have generated prebuilds for your native module using a tool like `prebuildify` and that they are correctly packaged. Alternatively, run `npm install --build-from-source` to attempt compilation from source (requires `node-gyp` tools).
Install `node-gyp`'s prerequisites for your operating system (e.g., `npm install --global windows-build-tools` on Windows, build-essential on Linux). Review your `binding.gyp` for errors.
Ensure your prebuilds are compatible with the Node.js ABI you are running (rebuild them if Node.js version changed). If compiling from source, ensure `node-gyp` is correctly configured.
Verify that your C++ code correctly exports the function and that your `binding.gyp` file specifies the correct entry point. Ensure `loadNativeBinding(__dirname)` points to the correct native module.
No dependency data recorded yet.