nwjs / nw-gyp

native addon build tool for node-webkit
MIT License
195 stars 46 forks source link

"Invalid version number" error when building project with npm on Windows #115

Open djipco opened 6 years ago

djipco commented 6 years ago

I'm trying to move a project from macOS to Windows. The project uses two native modules: serialport and opencv4nodejs. Everything works fine on macOS.

When I run npm install on Windows 10 (after having deleted the node_modules folder and carefully followed the instructions), I get an "Invalid version number" error.

I'm using nw-gyp@3.6.3. Here is what I enter on the command line:

PS C:\Users\jpcote\Desktop\50e\package.nw> set PYTHON=C:\Python27\python.exe
PS C:\Users\jpcote\Desktop\50e\package.nw> set npm_config_target=0.27.1
PS C:\Users\jpcote\Desktop\50e\package.nw> set npm_config_arch=x64
PS C:\Users\jpcote\Desktop\50e\package.nw> set npm_config_runtime=node-webkit
PS C:\Users\jpcote\Desktop\50e\package.nw> set npm_config_build_from_source=true
PS C:\Users\jpcote\Desktop\50e\package.nw> set npm_config_node_gyp=C:\Users\jpcote\AppData\Roaming\npm\node_modules\nw-gyp\bin\nw-gyp.js
PS C:\Users\jpcote\Desktop\50e\package.nw> npm install --msvs_version=2015

Here is the output I get:

> 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:73: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:493: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 Process.ChildProcess._handle.onexit (internal/child_process.js:220:5)
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"
gyp ERR! cwd C:\Users\jpcote\Desktop\50e\package.nw\node_modules\serialport
gyp ERR! node -v v9.2.1
gyp ERR! nw-gyp -v v3.6.3
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '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' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (C:\Users\jpcote\Desktop\50e\package.nw\node_modules\serialport\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:159:13)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:943:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5)
node-pre-gyp ERR! System Windows_NT 10.0.16299
node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\jpcote\\Desktop\\50e\\package.nw\\node_modules\\serialport\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd C:\Users\jpcote\Desktop\50e\package.nw\node_modules\serialport
node-pre-gyp ERR! node -v v9.2.1
node-pre-gyp ERR! node-pre-gyp -v v0.6.32
node-pre-gyp ERR! not ok
Failed to execute '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' (1)
npm WARN Error: EPERM: operation not permitted, scandir 'C:\Users\jpcote\Desktop\50e\package.nw\node_modules\serialport\node_modules\node-pre-gyp\node_modules\request\node_modules\combined-stream\node_modules'
npm WARN  { Error: EPERM: operation not permitted, scandir 'C:\Users\jpcote\Desktop\50e\package.nw\node_modules\serialport\node_modules\node-pre-gyp\node_modules\request\node_modules\combined-stream\node_modules'
npm WARN   stack: 'Error: EPERM: operation not permitted, scandir \'C:\\Users\\jpcote\\Desktop\\50e\\package.nw\\node_modules\\serialport\\node_modules\\node-pre-gyp\\node_modules\\request\\node_modules\\combined-stream\\node_modules\'',
npm WARN   errno: -4048,
npm WARN   code: 'EPERM',
npm WARN   syscall: 'scandir',
npm WARN   path: 'C:\\Users\\jpcote\\Desktop\\50e\\package.nw\\node_modules\\serialport\\node_modules\\node-pre-gyp\\node_modules\\request\\node_modules\\combined-stream\\node_modules' }
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! serialport@4.0.7 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the serialport@4.0.7 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\jpcote\AppData\Roaming\npm-cache\_logs\2017-12-12T15_14_01_119Z-debug.log
rogerwang commented 6 years ago

As I commented here https://github.com/nwjs/nw-gyp/issues/107#issuecomment-350944606 it works for me.

From your log I can see that 'node-pre-gyp' calls 'nw-gyp' without proper arguments so 'nw-gyp' failed. I'm not sure whether it's an issue in 'node-pre-gyp' but it doesn't run here when I tried to reproduce your issue.

rogerwang commented 6 years ago

Maybe it's something in your package.json. You could try my simple package.json in your system first to isolate other causes.

djipco commented 6 years ago

You could try my simple package.json in your system first to isolate other causes.

I just did. Same result. Problem remains.

rogerwang commented 6 years ago

Maybe you installed node-pre-gyp globally. I don't have that in my system.

djipco commented 6 years ago

At first, I did not. Then, I installed it to see if it would fix the problem. I just removed it.

rogerwang commented 6 years ago

The root cause of your issue is that nw-gyp is not properly called by node-pre-gyp, which is not supposed to be running at all if a simple serialport is being installed.

djipco commented 6 years ago

I understand that node-pre-gyp is not relaying the version information, but I'm not sure why it shouldn't be running... In all honesty, I'm a bit out of my league here.

I filed an issue with node-pre-gyp in case you want to supply more information to them.

I'm not sure what more I can do... this is so disheartening.

rogerwang commented 6 years ago

Why it should? It doesn't even exist in my system.

On Dec 13, 2017 12:19 AM, "Jean-Philippe Côté" notifications@github.com wrote:

I understand that node-pre-gyp is not relaying the version information, but I'm not sure why it shouldn't be running... In all honesty, I'm a bit out of my league here.

I filed an issue with node-pre-gyp https://github.com/mapbox/node-pre-gyp/issues/338 in case you want to supply more information to them.

I'm not sure what more I can do... this is so disheartening.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/nwjs/nw-gyp/issues/115#issuecomment-351101989, or mute the thread https://github.com/notifications/unsubscribe-auth/ASrVCXYFgKwK3EEKhT88a5EY6Fy09wTmks5s_qd5gaJpZM4Q_KFl .

rogerwang commented 6 years ago

You could try to find out how node-pre-gyp was installed in your system.

djipco commented 6 years ago

I did not install node-pre-gyp. I don't even really know what it is or what it does. I'm just trying to use native modules...

djipco commented 6 years ago

When I manually rebuild both modules (serialport & opencv4nodejs) with nw-gyp rebuild --target=0.27.1 --arch=x64. It works.

However, when I start my app, it cannot find one of the modules. The file is there (I triple-checked) but it says it can't find it:

Uncaught Error: The specified module could not be found.
\\?\C:\Users\jpcote\Desktop\50e\package.nw\node_modules\opencv4nodejs\build\Release\opencv4nodejs.node
    at Object.Module._extensions..node (module.js:713:18)
    at Module.load (module.js:585:32)
    at tryModuleLoad (module.js:528:12)
    at Function.Module._load (module.js:520:3)
    at Module.require (module.js:610:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (C:\Users\jpcote\Desktop\50e\package.nw\node_modules\opencv4nodejs\lib\opencv4nodejs.js:7:8)
    at Module._compile (module.js:666:30)
    at Object.Module._extensions..js (module.js:683:10)
    at Module.load (module.js:585:32)
GnorTech commented 6 years ago

It often means some dependency DLLs are not in the correct PATH

On Dec 13, 2017 6:25 AM, "Jean-Philippe Côté" notifications@github.com wrote:

When I manually rebuild both modules (serialport & opencv4nodejs) with nw-gyp rebuild --target=0.27.1 --arch=x64. It works.

However, when I start my app, it cannot find one of the modules. The file is there (I triple-checked) but it says it can't find it:

Uncaught Error: The specified module could not be found. \?\C:\Users\jpcote\Desktop\50e\package.nw\node_modules\opencv4nodejs\build\Release\opencv4nodejs.node at Object.Module._extensions..node (module.js:713:18) at Module.load (module.js:585:32) at tryModuleLoad (module.js:528:12) at Function.Module._load (module.js:520:3) at Module.require (module.js:610:17) at require (internal/module.js:11:18) at Object. (C:\Users\jpcote\Desktop\50e\package.nw\node_modules\opencv4nodejs\lib\opencv4nodejs.js:7:8) at Module._compile (module.js:666:30) at Object.Module._extensions..js (module.js:683:10) at Module.load (module.js:585:32)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/nwjs/nw-gyp/issues/115#issuecomment-351215639, or mute the thread https://github.com/notifications/unsubscribe-auth/AEB5QviXfLWr-Kwsp9D01y3FGLyMQbi_ks5s_v1pgaJpZM4Q_KFl .

djipco commented 6 years ago

@GnorTech Thanks. Any idea what I can do about this? I guess I'll file an issue on the module's GitHub.

GnorTech commented 6 years ago

It may not be an issue in it. First you can try to make it work with Node.js on Windows.

GnorTech commented 6 years ago

PS: on your last comment, you may not install node-pre-gyp by yourself, but it may be get installed by dependencies. That's why Roger suggested starting with a simple bare package.json to isolate causes. At least it was never installed in our test environment trying to reproduce your issue.

djipco commented 6 years ago

Even with a bare package the problem is still there. It's probably something with the opencv4nodejs module or my own configuration of OpenCV. Thanks for your help.

The original problem still remains though. I'm not sure how to address it. Anyway, thanks.

gpetrov commented 4 years ago

wondering if this was solved? I got the same problem when compiling nodegit under nwjs 0.40.2