zeromq.js
zeromq.js copied to clipboard
"No native build was found ……" error when use webpack and electron
Describe the bug I made a project with electron,vue and webpack. when i " import zmq from 'zeromq'" in my project. When I start my project by webpack devServer,the chrome devtools report the error like :
Uncaught Error: No native build was found for platform=win32 arch=x64 runtime=electron abi=89 uv=1 libc=glibc node=14.16.0 electron=13.1.7 webpack=true
loaded from: C:\Users\birui\Desktop\monitor\node_modules\electron\dist\resources\electron.asar\renderer
at Function.load.path (index.js:59)
at load (index.js:21)
at eval (binding.js:1)
at Object../node_modules/zeromq/binding.js (renderer.js:2619)
at __webpack_require__ (renderer.js:2745)
at fn (renderer.js:2944)
at eval (index.js:6)
at Object../node_modules/zeromq/lib/index.js (renderer.js:2639)
at __webpack_require__ (renderer.js:2745)
at fn (renderer.js:2944)
Tested on
- OS: Windows 10
- ZeroMQ.js version: 5.2.8
- Node.js:16.4.2
- Webpack:5.46.0
- Electron:13.1.7
I'm currently stuck on Electron 10 (with Nodejs v14) for a similar reason.
If I remember correctly, using ZeroMQ.js version: 6.0.0-beta6 worked, but then it doesn't work for all Windows versions.
I'm assuming updating line 30 and 31 in package.json would allow for additional electron prebuilds to be generated? https://github.com/zeromq/zeromq.js/blob/5.x/package.json#L30
I'm assuming updating line 30 and 31 in package.json would allow for additional electron prebuilds to be generated? https://github.com/zeromq/zeromq.js/blob/5.x/package.json#L30
I use Electron@3 and [email protected] ,node@10, this is a stable version stack. If you do not have electron/node version demand, you can try this stack.
I use Electron@3 and [email protected] ,node@10, this is a stable version stack. If you do not have electron/node version demand, you can try this stack.
Yeah, unfortunately in my case, there is a dependency on node v14 particularly, and a higher electron version. But reverting back to v5.2.0 for zmq might be worth a shot nonetheless...
You'd want to take a look at https://github.com/zeromq/zeromq.js/issues/384, similar issue. I got the development mode to work, using an external
, and I am testing the bundle, though I suspect this external thing in Webpack will fail the bundle.
I'll try 5.2.0 as well (coming from Zerorpc, it uses 4.x but doesn't work see https://github.com/0rpc/zerorpc-node so I need an upgrade to v5).
Version before Electron 7 should probably be avoided these days, they lake secure invoke
method and a lot of security updates.
I think I am stuck at Electron v13, so at least I can upgrade to Electron v12 and use Node 14. Starting Electron 13 electron-rebuild won't work correctly with zeromq.
I was getting the same error with Electron React Boilerplate.
When building a electron app with webpack, make sure you have any native modules (zeroMQ) in the correct location.
As per Electron React Boilerplate's. docs, webpack doesn't build great with native dependices. So, they split package.json into two different file locations.
I found that the branch seperate-electron-builds has some misleading information in the readme (at least for me). It says to use npm install [email protected]
but when I used this version it didn't even have the script/build.ts file.
Use npm install [email protected]
instead. This was able to electron rebuild
correctly and I have verified that ZeroMQ's native module has basic compatibility with Electron React Boilerplate in a built application.
if you are still having issues try using:
cd path/to/node_modules/zeromq
node-gyp build --verbose
More specifically, --verbose
will give you more details about the failed build. From there you can hopefully spot the build error.
I personally would like to request for more documentation for this subject. More specifically, how to properly distribute electron with ZeroMQ.
Thanks!
It says to use
npm install [email protected]
but when I used this version it didn't even have the script/build.ts file.
Use
npm install [email protected]
instead.
These are the same. Please clarify @b-smiley
It says to use
npm install [email protected]
but when I used this version it didn't even have the script/build.ts file.Use
npm install [email protected]
instead.These are the same. Please clarify @b-smiley
Apologies.
What I really meant to say is the version they recommended (beta.10) was missing a file (believe it was build.ts). I simply used the most recent version of that repository instead for the version they recommended in the README.
You should be able to just change the '10' to the most recent version of that branch.
Let me know if that works.