nw-gyp will not build without "target" (even though it is already configured)
brandonkirsch opened this issue · comments
I started a new project that uses node-ffi to interface with a 32-bit Windows .DLL.
I have no problems building for Node 7.6.0 (Win x86) but I get the following error when trying to build node-ffi for nwjs@0.20.3 / node@7.60 / nw-gyp@3.4.0:
1. Clean
bkirsch@BKIRSCH-T440S MINGW64 /c/bdk/nwjs-jde/node_modules/ffi
$ nw-gyp clean
gyp info it worked if it ends with ok
gyp info using nw-gyp@3.4.0
gyp info using node@7.6.0 | win32 | ia32
gyp info ok
2. Configure
$ nw-gyp configure --target="0.20.3"
gyp info it worked if it ends with ok
gyp info using nw-gyp@3.4.0
gyp info using node@7.6.0 | win32 | ia32
gyp info spawn C:\Python27\python.EXE
gyp info spawn args [ 'C:\Users\bkirsch\AppData\Roaming\npm\node_modules\nw-gyp\gyp\gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'msvs',
gyp info spawn args '-G',
gyp info spawn args 'msvs_version=auto',
gyp info spawn args '-I',
gyp info spawn args 'C:\bdk\nwjs-jde\node_modules\ffi\build\config.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\Users\bkirsch\AppData\Roaming\npm\node_modules\nw-gyp\addon.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\Users\bkirsch\.nw-gyp\0.20.3\common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=C:\Users\bkirsch\.nw-gyp\0.20.3',
gyp info spawn args '-Dnode_gyp_dir=C:\Users\bkirsch\AppData\Roaming\npm\node_modules\nw-gyp',
gyp info spawn args '-Dnode_lib_file=nw.lib',
gyp info spawn args '-Dmodule_root_dir=C:\bdk\nwjs-jde\node_modules\ffi',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '-Dv13=1',
gyp info spawn args '--generator-output',
gyp info spawn args 'C:\bdk\nwjs-jde\node_modules\ffi\build',
gyp info spawn args '-Goutput_dir=.' ]
gyp info ok
3. Build (throws error)
$ nw-gyp build
gyp info it worked if it ends with ok
gyp info using nw-gyp@3.4.0
gyp info using node@7.6.0 | win32 | ia32
gyp ERR! UNCAUGHT EXCEPTION
gyp ERR! stack TypeError: Invalid Version: undefined
gyp ERR! stack at new SemVer (C:\Users\bkirsch\AppData\Roaming\npm\node_modules\nw-gyp\node_modules\semver\semver.js:279:11)
gyp ERR! stack at compare (C:\Users\bkirsch\AppData\Roaming\npm\node_modules\nw-gyp\node_modules\semver\semver.js:566:10)
gyp ERR! stack at Function.gt (C:\Users\bkirsch\AppData\Roaming\npm\node_modules\nw-gyp\node_modules\semver\semver.js:595:10)
gyp ERR! stack at C:\Users\bkirsch\AppData\Roaming\npm\node_modules\nw-gyp\lib\build.js:67:22
gyp ERR! stack at C:\Users\bkirsch\AppData\Roaming\npm\node_modules\nw-gyp\node_modules\graceful-fs\graceful-fs.js:78:16
gyp ERR! stack at tryToString (fs.js:447:3)
gyp ERR! stack at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:434:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\Program Files (x86)\nodejs\node.exe" "C:\Users\bkirsch\AppData\Roaming\npm\node_modules\nw-gyp\bin\nw-gyp.js" "build"
gyp ERR! cwd C:\bdk\nwjs-jde\node_modules\ffi
gyp ERR! node -v v7.6.0
gyp ERR! nw-gyp -v v3.4.0
gyp ERR! This is a bug in nw-gyp
.
gyp ERR! Try to update node-gyp and file an Issue if it does not help:
gyp ERR! https://github.com/nwjs/nw-gyp/issues
I did some digging and found a nearly empty variable named "release" in build.js:build() function. After a little more digging, I found the nw-process-release.js:processRelease() function and saw that it inspects "argv" -- I was finally able to resolve my problem by specifying "target" with the "nw-gyp build" command:
** Build (working!) **
$ nw-gyp build --target="0.20.3"
It seems buggy to me that the target is lost between "nw-gyp configure" and "nw-gyp build"
Thank you ! you save me, i've same issue :
nw-gyp configure --target=0.21.2 // work
nw-gyp build // Error: Invalid version number: undefined
nw-gyp build --target=0.21.2 // work
I reported the same thing back in #97. Apparently the devs are in denial that this has even changed, and didn't bother updating the README to use the correct command.
I've switched our product over to electron since then, so we can use regular node-gyp now, which of course has its own problems, but at least we only have to set the --target
in configure
now!
I have the same issue. I'm trying to work on a project originally created on macOS from Windows 10. As usual, I'm deleting the node_modules
folder and issuing npm install
. This is what I'm getting:
[node-pre-gyp verb command build [ 'rebuild' ]
gyp ERR! configure error
gyp ERR! stack Error: Invalid version number: undefined
gyp ERR! stack at getNodeDir (C:\Users\jpcote\AppData\Roaming\npm\node_modules\nw-gyp\lib\configure.js:77:25)](url)
Obviously, I'm carefully following the instructions in the NW.js documentation. In fact, I'm the one who updated those instructions last time I had to go through this ordeal...
Can a kind soul tell me what needs to be done differently from those instructions? I'll happily update them with whatever changes are needed.
Thank you.
It works for me with the native module in our CI tests: https://github.com/nwjs/nw.js/tree/nw27/test/sanity/native-module-buffer
Rogers-Mac-mini:native-module-buffer roger$ export npm_config_target=0.27.1
Rogers-Mac-mini:native-module-buffer roger$ export npm_config_arch=x64
Rogers-Mac-mini:native-module-buffer roger$ export npm_config_target_arch=x64
Rogers-Mac-mini:native-module-buffer roger$ export npm_config_runtime=node-webkit
Rogers-Mac-mini:native-module-buffer roger$ export npm_config_build_from_source=true
Rogers-Mac-mini:native-module-buffer roger$ export npm_config_node_gyp=$(which nw-gyp)
Rogers-Mac-mini:native-module-buffer roger$ npm install
> buffer_example@0.0.1 install /Users/roger/test/native-module-buffer
> node-gyp rebuild
CXX(target) Release/obj.target/buffer_example/buffer_example.o
SOLINK_MODULE(target) Release/buffer_example.node
npm notice created a lockfile as package-lock.json. You should commit this file.
added 1 package in 28.277s
And nw-gyp rebuild
works too:
Rogers-Mac-mini:native-module-buffer roger$ nw-gyp rebuild
gyp info it worked if it ends with ok
gyp info using nw-gyp@3.6.2
gyp info using node@8.5.0 | darwin | x64
gyp info spawn /usr/bin/python
gyp info spawn args [ '/usr/local/lib/node_modules/nw-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/Users/roger/test/native-module-buffer/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/usr/local/lib/node_modules/nw-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/roger/.nw-gyp/0.27.1/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/Users/roger/.nw-gyp/0.27.1',
gyp info spawn args '-Dnode_gyp_dir=/usr/local/lib/node_modules/nw-gyp',
gyp info spawn args '-Dnode_lib_file=/Users/roger/.nw-gyp/0.27.1/<(target_arch)/node.lib',
gyp info spawn args '-Dnw_lib_file=/Users/roger/.nw-gyp/0.27.1/<(target_arch)/nw.lib',
gyp info spawn args '-Dmodule_root_dir=/Users/roger/test/native-module-buffer',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '-Dv13=1',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.' ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
CXX(target) Release/obj.target/buffer_example/buffer_example.o
SOLINK_MODULE(target) Release/buffer_example.node
gyp info ok
@rogerwang Yes, it works on macOS but not on Windows.
@cotejp on Windows it's working for me with nw-gyp@3.4.0. With nw-gyp 3.6.2 it's reporting an error with configure step but different from yours: The system cannot find the path specified
, which I'll fix soon.
Can you provide more information which would be helpful to reproduce your error? Like MSVS version.
@rogerwang Here is the full set of commands I used to try to compile/install all required modules. The project uses two native modules: serialport
and openccv4nodejs
.
set PYTHON=C:\Python27\python.exe
set npm_config_target=0.27.1
set npm_config_arch=x64
set npm_config_runtime=node-webkit
set npm_config_build_from_source=true
set npm_config_node_gyp=C:\Users\jpcote\AppData\Roaming\npm\node_modules\nw-gyp\bin\nw-gyp.js
npm install --msvs_version=2015
This is the first part of the output I'm getting (sorry for the length):
> serialport@4.0.7 install C:\Users\jpcote\Desktop\50e\package.nw\node_modules\serialport
> node-pre-gyp install --fallback-to-build
node-pre-gyp info it worked if it ends with ok
node-pre-gyp verb cli [ 'C:\\Program Files\\nodejs\\node.exe',
node-pre-gyp verb cli 'C:\\Users\\jpcote\\Desktop\\50e\\package.nw\\node_modules\\serialport\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp',
node-pre-gyp verb cli 'install',
node-pre-gyp verb cli '--fallback-to-build' ]
node-pre-gyp info using node-pre-gyp@0.6.32
node-pre-gyp info using node@9.2.1 | win32 | x64
node-pre-gyp verb command install []
node-pre-gyp info check checked for "C:\Users\jpcote\Desktop\50e\package.nw\node_modules\serialport\build\Release\serialport.node" (not found)
node-pre-gyp http GET https://github.com/EmergingTechnologyAdvisors/node-serialport/releases/download/4.0.7/serialport-v4.0.7-node-v59-win32-x64.tar.gz
node-pre-gyp http 404 https://github.com/EmergingTechnologyAdvisors/node-serialport/releases/download/4.0.7/serialport-v4.0.7-node-v59-win32-x64.tar.gz
node-pre-gyp ERR! Tried to download(404): https://github.com/EmergingTechnologyAdvisors/node-serialport/releases/download/4.0.7/serialport-v4.0.7-node-v59-win32-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for serialport@4.0.7 and node@9.2.1 (node-v59 ABI) (falling back to source compile with node-gyp)
node-pre-gyp http 404 status code downloading tarball https://github.com/EmergingTechnologyAdvisors/node-serialport/releases/download/4.0.7/serialport-v4.0.7-node-v59-win32-x64.tar.gz
node-pre-gyp verb command build [ 'rebuild' ]
gyp ERR! configure error
gyp ERR! stack Error: Invalid version number: undefined
gyp ERR! stack at getNodeDir (C:\Users\jpcote\AppData\Roaming\npm\node_modules\nw-gyp\lib\configure.js:77:25)
gyp ERR! stack at PythonFinder.callback (C:\Users\jpcote\AppData\Roaming\npm\node_modules\nw-gyp\lib\configure.js:45:7)
gyp ERR! stack at PythonFinder.<anonymous> (C:\Users\jpcote\AppData\Roaming\npm\node_modules\nw-gyp\lib\configure.js:497:14)
gyp ERR! stack at ChildProcess.exithandler (child_process.js:264:7)
gyp ERR! stack at ChildProcess.emit (events.js:159:13)
gyp ERR! stack at maybeClose (internal/child_process.js:943:16)
gyp ERR! stack at Socket.stream.socket.on (internal/child_process.js:363:11)
gyp ERR! stack at Socket.emit (events.js:159:13)
gyp ERR! stack at Pipe._handle.close [as _onclose] (net.js:558:12)
gyp ERR! System Windows_NT 10.0.16299
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\jpcote\\AppData\\Roaming\\npm\\node_modules\\nw-gyp\\bin\\nw-gyp.js" "configure" "--fallback-to-build" "--module=C:\\Users\\jpcote\\Desktop\\50e\\package.nw\\node_modules\\serialport\\build\\Release\\serialport.node" "--module_name=serialport" "--module_path=C:\\Users\\jpcote\\Desktop\\50e\\package.nw\\node_modules\\serialport\\build\\Release" "--msvs_version=2015"
I'm using nw-gyp v3.6.2. Thanks for your help!
In an empty dir I created this file
{
"dependencies": {
"serialport": "latest"
}
}
nw-gyp 3.4.0 works fine with or without npm. 3.6.2: the same error in my previous comment.
Yours error log shows that node-pre-gyp
calls nw-gyp
without proper arguments in the last line. Here node-pre-gyp
seems not running at all.
close as the document link has been added for the proper usage.
@cotejp your issue should be a different one. Please file another issue if you need further help. btw, we'll push 3.6.3 soon for the error found on windows.
close as the document link has been added for the proper usage.
I'm sorry but I don't understand this answer. I carefully followed the instructions. In fact, as I stated above, I'm the last person who updated those instructions.
I guess I'll file another issue...