zeromq.js icon indicating copy to clipboard operation
zeromq.js copied to clipboard

"No native build was found ……" error when use webpack and electron

Open lvbirui opened this issue 3 years ago • 8 comments

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

lvbirui avatar Jul 31 '21 07:07 lvbirui

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.

zaSmilingIdiot avatar Aug 11 '21 08:08 zaSmilingIdiot

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

zaSmilingIdiot avatar Aug 11 '21 09:08 zaSmilingIdiot

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.

lvbirui avatar Aug 13 '21 10:08 lvbirui

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...

zaSmilingIdiot avatar Aug 17 '21 10:08 zaSmilingIdiot

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.

eric-burel avatar Jan 04 '22 09:01 eric-burel

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!

b-smiley avatar Aug 15 '23 03:08 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

nrkramer avatar Dec 29 '23 01:12 nrkramer

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.

b-smiley avatar Dec 30 '23 18:12 b-smiley