Open masonctaylor opened 5 years ago
If you check this file:
https://github.com/zeromq/zeromq.js/blob/master/.travis.yml
It seems like one of the env
parameters has the value of ELECTRON="3.0.0"
.
I am not a travis expert and I have no clue, what does that mean really, but I think that's why you can't rebuild it to Electron 4.
I am using zmq with Electron 3, and I can't go to higher version of Electron, probalby becasue of that.
It would be nice, if someone much smarter than I am, could provide a fix or workaround for that issue.
Any updates on this? I'm using electron 5 and having this same issue when trying to run the app on windows. I tried npm rebuild zeromq --runtime=electron --target=5.0.0
and it had no effect.
seems same error, please see my answer in this post A dynamic link library (DLL) initialization routine failed
solution is:
Change
node\_modules\\zerorpc\\node\_modules\\zeromq\\lib\\index.js
from
var EventEmitter = require('events').EventEmitter
, zmq = require('../build/Release/zmq.node')
, util = require('util');
to:
var EventEmitter = require('events').EventEmitter
let path = require('path')
let zmqNodePath = path.join("..", "build", "Release", "zmq.node")
var zmq = require(zmqNodePath)
var util = require('util')
I'm seeing this error to when trying with "zeromq": "6.0.0-beta.17"
and "electron": "27.0.2"
. I followed instructions in this comment (https://github.com/zeromq/zeromq.js/issues/384#issuecomment-742630085) to get the build to succeed using electron-forge
, but then I hit the "not a valid Win32" error at runtime. I'm a at loss now, if anyone has any guidance that'd be great! The above comment doesn't seem to apply to the latest version anymore, and I'm seeing other issues when downgrading.
@mccauleyp Did you try with the prebuilds?
@mccauleyp Did you try with the prebuilds?
@aminya, thanks for your question!
Apologies, not 100% sure. I thought that simply doing npm install zeromq@6.0.0-beta.17
would use the prebuilt binaries if they were available. Do you mean something different than that? For context, I'm running this in a GitHub Action on ubuntu-latest
, so building on Linux for Windows. My forge/webpack configs look almost exactly like this one (https://github.com/zeromq/zeromq.js/issues/384#issuecomment-742630085), except in webpack.main.config.ts
, I have:
externals: {
zeromq: "zeromq",
},
(i.e. zeromq
instead of zeropc
), and in forge.config.ts
the hooks are modified slightly from the linked example to be:
hooks: {
packageAfterCopy: async (
_forgeOptions,
buildPath,
_electronVersion,
_platform,
_arch,
) => {
await runNpmCmd(
"Installing zeromq to packaged application...",
`npm install zeromq@${packageInfo.dependencies.zeromq}`,
buildPath,
);
},
},
I am not sure if cross-compiling for Windows from Linux is supported. The prebuilds will be automatically selected, but it seems your cross-compiling setup makes it not work. Try using windows-latest
I am not sure if cross-compiling for Windows from Linux is supported. The prebuilds will be automatically selected, but it seems your cross-compiling setup makes it not work. Try using
windows-latest
@aminya, Thanks for your suggestion! I've switched the GitHub Action to use windows-latest
. The pre-built binary installs as expected outside of the electron-forge
build process, which is enough to run my unit tests, but the npm install zeromq
inside the packageAfterCopy
hook inside forge.config.ts
doesn't seem to pull the prebuild and instead tries building from source. That build fails, and I'm trying to debug that now. If I remove the packageAfterCopy
hook entirely, the build succeeds, but I get the same Error: No native build was found for platform=win32 arch=x64 runtime=electron abi=118 uv=1 libc=glibc node=18.17.1 electron=27.0.2 webpack=true
that discussed here: https://github.com/zeromq/zeromq.js/issues/384.
electron-forge
automatically runs electron-rebuild
, so that might be why the build is getting triggers inside the Electron build even though it might not be necessary...
electron-forge
automatically runselectron-rebuild
, so that might be why the build is getting triggers inside the Electron build even though it might not be necessary...
Aha, this was the problem! The forge.config.ts
config above was fetching the prebuild, but then electron-rebuild
was trying to rebuild it and that build was failing. I disabled the rebuild by adding the following to forge.config.ts
:
rebuildConfig: {
onlyModules: [" "]
},
That just ensures that it doesn't try to rebuild anything. There's probably a better way to target just zeromq
, but right now zeromq
is the only thing I have that might need to be rebuilt, so this works for me.
I'm not sure why the rebuild is failing. I'm getting C compiler errors in the GitHub Action there. I tried taking some inspiration from your PR (https://github.com/zeromq/zeromq.js/pull/522/) by adding aminya/setup-cpp@v1
to the workflow, but that didn't do the trick. I don't really need to chase that down, though, so I'll just move forward with disabling the automatic rebuild.
Thanks very much for your input, @aminya !!!
You're welcome! Glad that it worked. It would be great if you can document your findings and make a merge request in case others run into the same issue,
v6 was released. Please try again with the latest version, and report back if the issue still persists. https://github.com/zeromq/zeromq.js/releases/tag/v6.0.0
Hi! So I am trying to create a (very) simple Electron app with (very) simple zeromq functionality, but am getting an error thrown from my
require('zeromq')
statement. My error seems to be similar to #242 , which was fixed by a prebuild-install update, but I'm still having this issue.Steps to Repro
var zmq = require("zeromq");
to main.jsVersions
Error message
App threw an error during load Error: \\?\C:\src\electron-quick-start\node_modules\zeromq\build\Release\zmq.node is not a valid Win32 application. \\?\C:\src\electron-quick-start\node_modules\zeromq\build\Release\zmq.node at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:160:31) at Object.Module._extensions..node (internal/modules/cjs/loader.js:722:18) at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:160:31) at Module.load (internal/modules/cjs/loader.js:602:32) at tryModuleLoad (internal/modules/cjs/loader.js:541:12) at Function.Module._load (internal/modules/cjs/loader.js:533:3) at Module.require (internal/modules/cjs/loader.js:640:17) at require (internal/modules/cjs/helpers.js:20:18) at Object.<anonymous> (C:\src\electron-quick-start\node_modules\zeromq\lib\index.js:6:11) at Object.<anonymous> (C:\src\electron-quick-start\node_modules\zeromq\lib\index.js:857:3)