Electron rebuild fails on Windows
What is wrong?
After installing brain.js, trying to run my electron app gives a node_module_version mismatch and when trying to run electron-rebuild.cmd a linker error is throwed
Where does it happen?
At electron's start (window doesn't show up, only an error dialog about node_module_version appears) and when executing electron-rebuild.cmd
How do we replicate the issue?
- Install brain.js
- Import it in main.js
- Run Electron (and fail)
[1]
[1] App threw an error during load
[1] Error: The module '\\?\C:\MX\Chero\node_modules\gl\build\Release\webgl.node'
[1] was compiled against a different Node.js version using
[1] NODE_MODULE_VERSION 72. This version of Node.js requires
[1] NODE_MODULE_VERSION 82. Please try re-compiling or re-installing
[1] the module (for instance, using `npm rebuild` or `npm install`).
[1] at process.func [as dlopen] (electron/js2c/asar.js:140:31)
[1] at Object.Module._extensions..node (internal/modules/cjs/loader.js:1196:18)
[1] at Object.func [as .node] (electron/js2c/asar.js:140:31)
[1] at Module.load (internal/modules/cjs/loader.js:981:32)
[1] at Module._load (internal/modules/cjs/loader.js:881:14)
[1] at Function.Module._load (electron/js2c/asar.js:769:28)
[1] at Module.require (internal/modules/cjs/loader.js:1023:19)
[1] at require (internal/modules/cjs/helpers.js:77:18)
[1] at bindings (C:\MX\Chero\node_modules\bindings\bindings.js:112:48)
[1] at Object.<anonymous> (C:\MX\Chero\node_modules\gl\src\javascript\native-gl.js:1:40)
- Run electron-rebuild (and fail again)
| Building module: gl, Completed: 0gyp info find Python using Python version 2.7.18 found at "C:\Python27\python.exe"
| Building module: gl, Completed: 0gyp info find VS using VS2017 (15.9.28307.1274) found at:
gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools"
gyp info find VS run with --verbose for detailed information
gyp info spawn C:\Python27\python.exe
gyp info spawn args [
gyp info spawn args 'C:\\MX\\Chero\\node_modules\\node-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 '-I',
gyp info spawn args 'C:\\MX\\Chero\\node_modules\\gl\\build\\config.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\\MX\\Chero\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\\MX\\Chero\\node_modules\\gl\\10.1.5\\include\\node\\common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=C:\\MX\\Chero\\node_modules\\gl\\10.1.5',
gyp info spawn args '-Dnode_gyp_dir=C:\\MX\\Chero\\node_modules\\node-gyp',
gyp info spawn args '-Dnode_lib_file=C:\\\\MX\\\\Chero\\\\node_modules\\\\gl\\\\10.1.5\\\\<(target_arch)\\\\node.lib',
gyp info spawn args '-Dmodule_root_dir=C:\\MX\\Chero\\node_modules\\gl',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'C:\\MX\\Chero\\node_modules\\gl\\build',
gyp info spawn args '-Goutput_dir=.'
gyp info spawn args ]
\ Building module: gl, Completed: 0gyp info spawn C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe
gyp info spawn args [
gyp info spawn args 'build/binding.sln',
gyp info spawn args '/clp:Verbosity=minimal',
gyp info spawn args '/nologo',
gyp info spawn args '/p:Configuration=Release;Platform=x64',
gyp info spawn args map: [Function]
gyp info spawn args ]
| Building module: gl, Completed: 0Compilazione dei progetti nella soluzione uno alla volta. Per abilitare la compilazione parallela, aggiungere l'opzione "/m".
\ Building module: gl, Completed: 0 Copying C:\MX\Chero\node_modules\gl/deps/windows/dll/x64/libEGL.dll to C:\MX\Chero\node_modules\gl\build\Release
1 file copiati.
Copying C:\MX\Chero\node_modules\gl/deps/windows/dll/x64/d3dcompiler_47.dll to C:\MX\Chero\node_modules\gl\build\Release
1 file copiati.
Copying C:\MX\Chero\node_modules\gl/deps/windows/dll/x64/libGLESv2.dll to C:\MX\Chero\node_modules\gl\build\Release
1 file copiati.
- Building module: gl, Completed: 0 bindings.cc
| Building module: gl, Completed: 0c:\mx\chero\node_modules\gl\10.1.5\include\node\v8.h(9113): warning C4996: 'v8::MicrotasksCompletedCallback': Use *WithData version. [C:\MX\Chero\node_modules\gl\build\webgl.vcxproj]
c:\mx\chero\node_modules\gl\10.1.5\include\node\v8.h(7322): note: vedere la dichiarazione di 'v8::MicrotasksCompletedCallback'
c:\mx\chero\node_modules\gl\10.1.5\include\node\v8.h(9121): warning C4996: 'v8::MicrotasksCompletedCallback': Use *WithData version. [C:\MX\Chero\node_modules\gl\build\webgl.vcxproj]
c:\mx\chero\node_modules\gl\10.1.5\include\node\v8.h(7322): note: vedere la dichiarazione di 'v8::MicrotasksCompletedCallback'
| Building module: gl, Completed: 0 webgl.cc
- Building module: gl, Completed: 0c:\mx\chero\node_modules\gl\10.1.5\include\node\v8.h(9113): warning C4996: 'v8::MicrotasksCompletedCallback': Use *WithData version. [C:\MX\Chero\node_modules\gl\build\webgl.vcxproj]
c:\mx\chero\node_modules\gl\10.1.5\include\node\v8.h(7322): note: vedere la dichiarazione di 'v8::MicrotasksCompletedCallback'
c:\mx\chero\node_modules\gl\10.1.5\include\node\v8.h(9121): warning C4996: 'v8::MicrotasksCompletedCallback': Use *WithData version. [C:\MX\Chero\node_modules\gl\build\webgl.vcxproj]
c:\mx\chero\node_modules\gl\10.1.5\include\node\v8.h(7322): note: vedere la dichiarazione di 'v8::MicrotasksCompletedCallback'
/ Building module: gl, Completed: 0c:\mx\chero\node_modules\gl\src\native\webgl.cc(463): warning C4312: 'reinterpret_cast': conversione da 'GLint' a 'GLvoid *', di dimensioni maggiori [C:\MX\Chero\node_modules\gl\build\webgl.vcxproj]
| Building module: gl, Completed: 0 procs.cc
- Building module: gl, Completed: 0c:\mx\chero\node_modules\gl\10.1.5\include\node\v8.h(9113): warning C4996: 'v8::MicrotasksCompletedCallback': Use *WithData version. [C:\MX\Chero\node_modules\gl\build\webgl.vcxproj]
c:\mx\chero\node_modules\gl\10.1.5\include\node\v8.h(7322): note: vedere la dichiarazione di 'v8::MicrotasksCompletedCallback'
c:\mx\chero\node_modules\gl\10.1.5\include\node\v8.h(9121): warning C4996: 'v8::MicrotasksCompletedCallback': Use *WithData version. [C:\MX\Chero\node_modules\gl\build\webgl.vcxproj]
c:\mx\chero\node_modules\gl\10.1.5\include\node\v8.h(7322): note: vedere la dichiarazione di 'v8::MicrotasksCompletedCallback'
- Building module: gl, Completed: 0 win_delay_load_hook.cc
/ Building module: gl, Completed: 0 Creazione della libreria C:\MX\Chero\node_modules\gl\build\Release\webgl.lib e dell'oggetto C:\MX\Chero\node_modules\gl\build\Release\webgl.exp
- Building module: gl, Completed: 0webgl.obj : error LNK2019: riferimento al simbolo esterno "__declspec(dllimport) public: class std::shared_ptr<class v8::BackingStore> __cdecl v8::ArrayBuffer::GetBackingStore(void)" (__imp_?GetBackingStore@ArrayBuffer@v8@@QE
AA?AV?$shared_ptr@VBackingStore@v8@@@std@@XZ) non risolto nella funzione "public: __cdecl Nan::TypedArrayContents<char>::TypedArrayContents<char>(class v8::Local<class v8::Value>)" (??0?$TypedArrayContents@D@Nan@@QEAA@V?$Loca
l@VValue@v8@@@v8@@@Z) [C:\MX\Chero\node_modules\gl\build\webgl.vcxproj]
C:\MX\Chero\node_modules\gl\build\Release\webgl.node : fatal error LNK1120: 1 esterni non risolti [C:\MX\Chero\node_modules\gl\build\webgl.vcxproj]
ร Rebuild Failed
An unhandled error occurred inside electron-rebuild
node-gyp failed to rebuild 'C:\MX\Chero\node_modules\gl'.
Error: `C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe` failed with exit code: 1
Error: node-gyp failed to rebuild 'C:\MX\Chero\node_modules\gl'.
Error: `C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe` failed with exit code: 1
at ModuleRebuilder.rebuildNodeGypModule (C:\MX\Chero\node_modules\electron-rebuild\lib\src\module-rebuilder.js:193:19)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
Expected behavior
I don't know if it's usual that it throws the node module mismatch on windows, but I think it should build also with electron-rebuild(?), at least it does with simple npm build/rebuild.
Version information
Nodejs: v12.18.3
Electron: 10.1.5
Electron-rebuild: 2.3.2
Brain.js: 2.0.0-beta.2
How important is this (1-5)?
5, can't run my app on Windows
Issue-Label Bot is automatically applying the label bug to this issue, with a confidence of 0.92. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!
Links: app homepage, dashboard and code for this bot.
This seems to be issue with the gl module build issue. Can you please check and confirm if you are able to install this module (https://github.com/stackgl/headless-gl) in your electron app?
"npm install gl" goes flawlessly, but when trying to run electron-rebuild it throws the same error.
When importing gl in my electron app (and leaving Brain.js out) with this sample code:
var width = 64;
var height = 64;
var gl = require('gl')(width, height, { preserveDrawingBuffer: true });
the error is this:
[1] App threw an error during load
[1] Error: Could not locate the bindings file. Tried:
[1] โ C:\MX\Chero\node_modules\gl\build\Debug\webgl.node
[1] โ C:\MX\Chero\node_modules\gl\build\Release\webgl.node
[1] โ C:\MX\Chero\node_modules\gl\out\Debug\webgl.node
[1] โ C:\MX\Chero\node_modules\gl\Debug\webgl.node
[1] โ C:\MX\Chero\node_modules\gl\out\Release\webgl.node
[1] โ C:\MX\Chero\node_modules\gl\Release\webgl.node
[1] โ C:\MX\Chero\node_modules\gl\build\default\webgl.node
[1] โ C:\MX\Chero\node_modules\gl\compiled\12.16.3\win32\x64\webgl.node
[1] โ C:\MX\Chero\node_modules\gl\addon-build\release\install-root\webgl.node
[1] โ C:\MX\Chero\node_modules\gl\addon-build\debug\install-root\webgl.node
[1] โ C:\MX\Chero\node_modules\gl\addon-build\default\install-root\webgl.node
[1] โ C:\MX\Chero\node_modules\gl\lib\binding\node-v82-win32-x64\webgl.node
[1] at bindings (C:\MX\Chero\node_modules\bindings\bindings.js:126:9)
[1] at Object.<anonymous> (C:\MX\Chero\node_modules\gl\src\javascript\native-gl.js:1:40)
[1] at Module._compile (internal/modules/cjs/loader.js:1145:30)
[1] at Object.Module._extensions..js (internal/modules/cjs/loader.js:1166:10)
[1] at Module.load (internal/modules/cjs/loader.js:981:32)
[1] at Module._load (internal/modules/cjs/loader.js:881:14)
[1] at Function.Module._load (electron/js2c/asar.js:769:28)
[1] at Module.require (internal/modules/cjs/loader.js:1023:19)
[1] at require (internal/modules/cjs/helpers.js:77:18)
[1] at Object.<anonymous> (C:\MX\Chero\node_modules\gl\src\javascript\webgl-rendering-context.js:4:58)
then after executing "npm rebuild" and trying to run the app the error is the same as before:
[1] App threw an error during load
[1] Error: The module '\\?\C:\MX\Chero\node_modules\gl\build\Release\webgl.node'
[1] was compiled against a different Node.js version using
[1] NODE_MODULE_VERSION 72. This version of Node.js requires
[1] NODE_MODULE_VERSION 82. Please try re-compiling or re-installing
[1] the module (for instance, using `npm rebuild` or `npm install`).
[1] at process.func [as dlopen] (electron/js2c/asar.js:140:31)
[1] at Object.Module._extensions..node (internal/modules/cjs/loader.js:1196:18)
[1] at Object.func [as .node] (electron/js2c/asar.js:140:31)
[1] at Module.load (internal/modules/cjs/loader.js:981:32)
[1] at Module._load (internal/modules/cjs/loader.js:881:14)
[1] at Function.Module._load (electron/js2c/asar.js:769:28)
[1] at Module.require (internal/modules/cjs/loader.js:1023:19)
[1] at require (internal/modules/cjs/helpers.js:77:18)
[1] at bindings (C:\MX\Chero\node_modules\bindings\bindings.js:112:48)
[1] at Object.<anonymous> (C:\MX\Chero\node_modules\gl\src\javascript\native-gl.js:1:40)
This looks like build setup issues, can you please follow guide here: https://github.com/BrainJS/brain.js/issues/458
Already did it all, but the errors are still here. I even tried to repeat the procedure in a new Windows 10 VM, nothing changed.
I tried to go further following the electron's guide for building native modules with node-gyp and it's stuck on this error:
PS C:\MX\Chero\node_modules\gl> node-gyp rebuild --target=1.2.3 --arch=x64 --dist-url=https://electronjs.org/headers
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp info find Python using Python version 2.7.18 found at "C:\Python27\python.exe"
gyp info find VS using VS2017 (15.9.28307.1274) found at:
gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools"
gyp info find VS run with --verbose for detailed information
gyp info spawn C:\Python27\python.exe
gyp info spawn args [
gyp info spawn args 'C:\\Users\\Max\\AppData\\Roaming\\npm\\node_modules\\node-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 '-I',
gyp info spawn args 'C:\\MX\\Chero\\node_modules\\gl\\build\\config.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\\Users\\Max\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\\Users\\Max\\AppData\\Local\\node-gyp\\Cache\\iojs-1.2.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\\Max\\AppData\\Local\\node-gyp\\Cache\\iojs-1.2.3',
gyp info spawn args '-Dnode_gyp_dir=C:\\Users\\Max\\AppData\\Roaming\\npm\\node_modules\\node-gyp',
gyp info spawn args '-Dnode_lib_file=C:\\\\Users\\\\Max\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\iojs-1.2.3\\\\<(target_arch)\\\\iojs.lib',
gyp info spawn args '-Dmodule_root_dir=C:\\MX\\Chero\\node_modules\\gl',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'C:\\MX\\Chero\\node_modules\\gl\\build',
gyp info spawn args '-Goutput_dir=.'
gyp info spawn args ]
gyp info spawn C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe
gyp info spawn args [
gyp info spawn args 'build/binding.sln',
gyp info spawn args '/clp:Verbosity=minimal',
gyp info spawn args '/nologo',
gyp info spawn args '/p:Configuration=Release;Platform=x64'
gyp info spawn args ]
Compilazione dei progetti nella soluzione uno alla volta. Per abilitare la compilazione parallela, aggiungere l'opzione "/m".
Copying C:\MX\Chero\node_modules\gl/deps/windows/dll/x64/libEGL.dll to C:\MX\Chero\node_modules\gl\build\Release
1 file copiati.
Copying C:\MX\Chero\node_modules\gl/deps/windows/dll/x64/d3dcompiler_47.dll to C:\MX\Chero\node_modules\gl\build\Release
1 file copiati.
Copying C:\MX\Chero\node_modules\gl/deps/windows/dll/x64/libGLESv2.dll to C:\MX\Chero\node_modules\gl\build\Release
1 file copiati.
bindings.cc
webgl.cc
c:\mx\chero\node_modules\gl\src\native\webgl.cc(463): warning C4312: 'reinterpret_cast': conversione da 'GLint' a 'GLvoid *', di dimensioni maggiori [C:\MX\Chero\node_modules\gl\build\webgl.vcxproj]
c:\mx\chero\node_modules\gl\src\native\webgl.cc(484): warning C4267: 'argomento': conversione da 'size_t' a 'GLsizei'. Possibile perdita di dati. [C:\MX\Chero\node_modules\gl\build\webgl.vcxproj]
c:\mx\chero\node_modules\gl\src\native\webgl.cc(494): warning C4267: 'argomento': conversione da 'size_t' a 'GLsizei'. Possibile perdita di dati. [C:\MX\Chero\node_modules\gl\build\webgl.vcxproj]
c:\mx\chero\node_modules\gl\src\native\webgl.cc(504): warning C4267: 'argomento': conversione da 'size_t' a 'GLsizei'. Possibile perdita di dati. [C:\MX\Chero\node_modules\gl\build\webgl.vcxproj]
c:\mx\chero\node_modules\gl\src\native\webgl.cc(782): warning C4244: '*=': conversione da 'double' a 'unsigned char'. Possibile perdita di dati. [C:\MX\Chero\node_modules\gl\build\webgl.vcxproj]
c:\mx\chero\node_modules\gl\src\native\webgl.cc(784): warning C4244: 'inizializzazione': conversione da 'double' a 'float'. Possibile perdita di dati. [C:\MX\Chero\node_modules\gl\build\webgl.vcxproj]
c:\mx\chero\node_modules\gl\src\native\webgl.cc(785): warning C4244: '*=': conversione da 'float' a 'unsigned char'. Possibile perdita di dati. [C:\MX\Chero\node_modules\gl\build\webgl.vcxproj]
c:\mx\chero\node_modules\gl\src\native\webgl.cc(786): warning C4244: '*=': conversione da 'float' a 'unsigned char'. Possibile perdita di dati. [C:\MX\Chero\node_modules\gl\build\webgl.vcxproj]
c:\mx\chero\node_modules\gl\src\native\webgl.cc(787): warning C4244: '*=': conversione da 'float' a 'unsigned char'. Possibile perdita di dati. [C:\MX\Chero\node_modules\gl\build\webgl.vcxproj]
c:\mx\chero\node_modules\gl\src\native\webgl.cc(794): warning C4244: 'inizializzazione': conversione da 'double' a 'float'. Possibile perdita di dati. [C:\MX\Chero\node_modules\gl\build\webgl.vcxproj]
c:\mx\chero\node_modules\gl\src\native\webgl.cc(795): warning C4244: '*=': conversione da 'float' a 'int'. Possibile perdita di dati. [C:\MX\Chero\node_modules\gl\build\webgl.vcxproj]
c:\mx\chero\node_modules\gl\src\native\webgl.cc(796): warning C4244: '*=': conversione da 'float' a 'int'. Possibile perdita di dati. [C:\MX\Chero\node_modules\gl\build\webgl.vcxproj]
c:\mx\chero\node_modules\gl\src\native\webgl.cc(797): warning C4244: '*=': conversione da 'float' a 'int'. Possibile perdita di dati. [C:\MX\Chero\node_modules\gl\build\webgl.vcxproj]
c:\mx\chero\node_modules\gl\src\native\webgl.cc(2084): error C2039: 'ToChecked': non รจ un membro di 'v8::Maybe<uint32_t>' [C:\MX\Chero\node_modules\gl\build\webgl.vcxproj]
c:\users\max\appdata\local\node-gyp\cache\iojs-1.2.3\deps\v8\include\v8.h(2034): note: vedere la dichiarazione di 'v8::Maybe<uint32_t>'
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Users\Max\AppData\Roaming\npm\node_modules\node-gyp\lib\build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:315:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Windows_NT 10.0.19041
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Max\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--target=1.2.3" "--arch=x64" "--dist-url=https://electronjs.org/headers"
gyp ERR! cwd C:\MX\Chero\node_modules\gl
gyp ERR! node -v v12.18.3
gyp ERR! node-gyp -v v7.1.2
gyp ERR! not ok
@MassimoMendozza try using some lower versions of node.js and node-gyp (for example 10.0 or lower), try nvm tool for that.
@Nelias Tried with nvm to use both node 10.23.0 and node 10.0.0 with multiple version of node-gyp (latest, 5.1.0 and 3.6.3).
Nothing changed, the errors are the same
This is an issue with https://github.com/stackgl/headless-gl, a dependency of GPU.js which is a peer-dependency of brain. Please communicate your issues there.
Is this resolved? I want to use brainJS on electron, and don't know if this is OK.
Version might be Electron Version: 22.0.0 Node Version: 16.17.1 Chromium Version: 108.0.5359.62
I don't believe so