nwjs / nw-gyp

native addon build tool for node-webkit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

nw-gyp build won't work without passing --target

DuBistKomisch opened this issue · comments

This is very strange since I'm sure it was working a few weeks ago...

I'm using Windows 8.1 + VS 2015 + node 4.2.6 32-bit + nw-gyp 3.4.0 + nwjs 0.12.2 (same issue occurs with e.g. 0.16.0 though).

PS C:\Users\jake\[redacted]> nw-gyp configure --target=0.12.2
gyp info it worked if it ends with ok
gyp info using nw-gyp@3.4.0
gyp info using node@4.2.6 | win32 | ia32
gyp info spawn C:\Python27\python.EXE
gyp info spawn args [ 'C:\\Users\\jake\\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:\\Users\\jake\\[redacted]\\build\\config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\jake\\AppData\\Roaming\\npm\\node_modules\\nw-gyp\\addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\jake\\.nw-gyp\\0.12.2\\common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=C:\\Users\\jake\\.nw-gyp\\0.12.2',
gyp info spawn args   '-Dnode_gyp_dir=C:\\Users\\jake\\AppData\\Roaming\\npm\\node_modules\\nw-gyp',
gyp info spawn args   '-Dnode_lib_file=nw.lib',
gyp info spawn args   '-Dmodule_root_dir=C:\\Users\\jake\\[redacted]',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '-Dv13=0',
gyp info spawn args   '--generator-output',
gyp info spawn args   'C:\\Users\\jake\\[redacted]\\build',
gyp info spawn args   '-Goutput_dir=.' ]
gyp info ok
PS C:\Users\jake\[redacted]> nw-gyp build
gyp info it worked if it ends with ok
gyp info using nw-gyp@3.4.0
gyp info using node@4.2.6 | win32 | ia32
gyp ERR! UNCAUGHT EXCEPTION
gyp ERR! stack TypeError: Invalid Version: undefined
gyp ERR! stack     at new SemVer (C:\Users\jake\AppData\Roaming\npm\node_modules\nw-gyp\node_modules\semver\semver.js:279:11)
gyp ERR! stack     at compare (C:\Users\jake\AppData\Roaming\npm\node_modules\nw-gyp\node_modules\semver\semver.js:566:10)
gyp ERR! stack     at Function.gt (C:\Users\jake\AppData\Roaming\npm\node_modules\nw-gyp\node_modules\semver\semver.js:595:10)
gyp ERR! stack     at C:\Users\jake\AppData\Roaming\npm\node_modules\nw-gyp\lib\build.js:67:22
gyp ERR! stack     at C:\Users\jake\AppData\Roaming\npm\node_modules\nw-gyp\node_modules\graceful-fs\graceful-fs.js:78:16
gyp ERR! stack     at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:380:3)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "C:\\Program Files (x86)\\nodejs\\node.exe" "C:\\Users\\jake\\AppData\\Roaming\\npm\\node_modules\\nw-gyp\\bin\\nw-gyp.js" "build"
gyp ERR! cwd C:\Users\jake\[redacted]
gyp ERR! node -v v4.2.6
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 looked into the code and it seems like it expects gyp.opts.target to be set, but it isn't. The generated build/config.gypi has variables.target set properly though, so not really sure what's going wrong. If I run nw-gyp build --target=0.12.2 it works since it also seems to check argv.

I can also confirm this.

--target is required since there is no way to detect which nw version you are building for.

That wasn't the behaviour prior to the version 3 merge, so I assume it was a change upstream, and there's no hope of it being reinstated. Should update the README, since it still uses just nw-gyp build.

We used to be able to follow the instructions in the NW.js documentation to compile native modules on Windows. Now, they do not work. Something must have changed.

It works for me. See my comments in #107