Windows 10 / 11 : nw-gyp not running with anything past Node 14.x; NPM keeps trying to use node-gyp instead
NbrTDB opened this issue · comments
This may be a more appropriate issue for the NPM repo, or perhaps NW.js... But I can't for the life of me get my NW.js project to build using any NW.js/Node combination that uses Node versions beyond Node 14 - it looks like nw-gyp
is not running at all, instead the build process always tries to use node-gyp
. It then explodes when node-gyp
misinterprets the npm_config_target
environment variable and starts trying to grab Node [whichever NW.js version was targeted here].
As soon as I switch back down to Node 14.x (say, 14.3.0, or 14.21.2) and try again, everything works perfectly, builds as expected, and my project is able to run. Interestingly, this is true up to NW.js 0.50.1, despite that theoretically wanting Node 15.3.0 for the build environment (if I actually try to use 15.3.0, the aforementioned issue with nw-gyp
occurs).
My project does have various dependencies that require nw-gyp
compilation (shown below, the package.json
dependencies that are valid for Node up to 14.21.2 - the last version before Node 15):
"dependencies": {
"@serialport/parser-inter-byte-timeout": "^8.0.4",
"JSONStream": "^1.3.5",
"better-sqlite3": "7.4.6",
"crc": "^3.8.0",
"exceljs": "^4.3.0",
"fs-extra": "^8.1.0",
"fs-filesystem": "^2.1.2",
"os": "^0.1.1",
"serialport": "^8.0.4",
"systeminformation": "^5.9.4",
"usb-detection": "^4.10.0",
"uuid": "^3.3.2",
"xlsx": "^0.17.2"
}
The build batchfile, at least the relevant parts, is essentially:
set PYTHON=C:\Python27\python.exe
set npm_config_target=0.50.1
set npm_config_arch=x64
set npm_config_runtime=node-webkit
set npm_config_build_from_source=true
set npm_config_node_gyp=%userprofile%\AppData\Roaming\npm\node_modules\nw-gyp\bin\nw-gyp.js
call npm install --msvs_version=2017