nw-gyp is a specialized build tool designed to compile native Node.js addons for use within NW.js (formerly node-webkit) applications. It functions as a 'hack' on `node-gyp`, adapting its build process to accommodate the specific headers and libraries required by NW.js, which often uses a different V8 version than standard Node.js. The current stable version is 3.6.8, last published 10 months ago, but the project's GitHub repository shows no significant activity since 2017. This indicates the tool is largely abandoned and is highly unlikely to be compatible with recent versions of NW.js or Node.js. Developers must manually specify the target NW.js version during the configuration step.
npm install nw-gypVerified import paths — ran on the pinned version, not inferred.
Demonstrates the global installation, configuration, and build steps for a native NW.js addon using the nw-gyp command-line interface, targeting an older, compatible NW.js version.
For newer NW.js projects, consider using `node-gyp` directly with appropriate flags, or explore alternative solutions if `node-gyp` itself proves insufficient for NW.js specific requirements in newer versions. Consult the official NW.js documentation for current recommendations on native module support.
Ensure Python 2.7 is installed and configured correctly in your system's PATH. If you have multiple Python versions, specify Python 2.7 using `nw-gyp --python /path/to/python2.7` or `npm config set python /path/to/executable/python2.7`.
Follow the installation instructions in the README for your specific operating system. On Windows, consider using `npm install --global --production windows-build-tools` from an elevated prompt to automate the setup. Ensure your Xcode Command Line Tools are installed and up-to-date on macOS.
Always include `--target=<NW.js_version_you_are_using>` (e.g., `--target=0.12.3`) when running `nw-gyp configure`. Also consider `--arch=x64` or `--arch=ia32` and, on Windows, `--msvs_version=<year>` for robust configuration.
Install Python 2.7, add it to your PATH, and then explicitly set its path: `npm config set python /path/to/python2.7` or run `nw-gyp --python /path/to/python2.7 ...`
Ensure `make` and a compatible C/C++ compiler (GCC, Xcode, Visual C++) are properly installed and accessible in your system's PATH according to your OS's requirements. Verify your `binding.gyp` syntax and C/C++ code.
Install Visual C++ Build Tools 2015 (or a version compatible with your NW.js target and nw-gyp version). Use `npm install --global --production windows-build-tools` or manually install Visual Studio 2015/2017 with the 'Common Tools for Visual C++' workload. Then, try setting `npm config set msvs_version 2015` or similar.
Verify your `--target` NW.js version is correct and accessible. Check your internet connection. If behind a proxy, configure `npm` and your system's proxy settings. Ensure the target version's headers are still available from NW.js build servers.
This specific issue indicates deep incompatibility. As `nw-gyp` is abandoned, this usually means the native module and `nw-gyp` are too far out of sync. Upgrading the native module or attempting to use a significantly older version of `nw-gyp` that matches the module's vintage might be the only (unlikely) solution. Generally, it signals a breaking change due to the abandonment status.