[英]Why is Nodejs usb module conflicting with Electron?
sorry for the long post, I've been googling a lot for a solution but couldn't find one.很抱歉这篇长文,我一直在谷歌上搜索一个解决方案,但找不到一个。 I'm trying to write a simple Electron app to display an html page (no problem with that thankfully) and to control a printer, thing that must be done through the usb module installed via npm. I'm trying to write a simple Electron app to display an html page (no problem with that thankfully) and to control a printer, thing that must be done through the usb module installed via npm. That module and the code that relies on it always worked perfectly in pure node.js software so that's not where to look for the problem, but I'm having a hard time integrating it in my Electron app.该模块和依赖它的代码总是在纯 node.js 软件中完美运行,所以这不是寻找问题的地方,但我很难将它集成到我的 Electron 应用程序中。 I have to use Ubuntu 14.04 , and the system already has node 12.20.0 + npm 6.14.8 , both installed via nvm without any warning (I can install different versions if there's any known conflict).我必须使用Ubuntu 14.04 ,并且系统已经有节点 12.20.0 + npm 6.14.8 ,都通过 nvm 安装而没有任何警告(如果有任何已知的冲突,我可以安装不同的版本)。 Due to a series of difficulties using Electron installed via npm, I resorted to using the prebuilt binaries package of it ( version 11.1.1 , but again that's something I can change if needed) that can be downloaded from https://github.com/electron/electron/releases/tag/v11.1.1 Due to a series of difficulties using Electron installed via npm, I resorted to using the prebuilt binaries package of it ( version 11.1.1 , but again that's something I can change if needed) that can be downloaded from https://github.com /electron/electron/releases/tag/v11.1.1
Here's what I do:这就是我所做的:
This is what I get:这就是我得到的:
./electron: /usr/lib/x86_64-linux-gnu/libxkbcommon.so.0: no version information available (required by ./electron)
/home/totem/totem/electron: /usr/lib/x86_64-linux-gnu/libxkbcommon.so.0: no version information available (required by /home/totem/totem/electron)
/home/totem/totem/electron: /usr/lib/x86_64-linux-gnu/libxkbcommon.so.0: no version information available (required by /home/totem/totem/electron)
Fontconfig warning: "/etc/fonts/fonts.conf", line 86: unknown element "blank"
A JavaScript error occurred in the main process
Uncaught Exception:
Error: The module '/home/totem/totem/resources/app/node_modules/usb/build/Release/usb_bindings.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 72. This version of Node.js requires
NODE_MODULE_VERSION 85. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
at process.func [as dlopen] (electron/js2c/asar_bundle.js:5:1812)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1203:18)
at Object.func [as .node] (electron/js2c/asar_bundle.js:5:1812)
at Module.load (internal/modules/cjs/loader.js:992:32)
at Module._load (internal/modules/cjs/loader.js:885:14)
at Function.f._load (electron/js2c/asar_bundle.js:5:12738)
at Module.require (internal/modules/cjs/loader.js:1032:19)
at require (internal/modules/cjs/helpers.js:72:18)
at bindings (/home/totem/totem/resources/app/node_modules/bindings/bindings.js:112:48)
at Object.<anonymous> (/home/totem/totem/resources/app/node_modules/usb/usb.js:1:57)
Segmentation fault
An unhandled error occurred inside electron-rebuild
Unable to find electron's version number, either install it or specify an explicit version
Error: Unable to find electron's version number, either install it or specify an explicit version
at /home/totem/totem/resources/app/node_modules/electron-rebuild/lib/src/cli.js:82:19
./electron: /usr/lib/x86_64-linux-gnu/libxkbcommon.so.0: no version information available (required by ./electron)
/home/totem/totem/electron: /usr/lib/x86_64-linux-gnu/libxkbcommon.so.0: no version information available (required by /home/totem/totem/electron)
/home/totem/totem/electron: /usr/lib/x86_64-linux-gnu/libxkbcommon.so.0: no version information available (required by /home/totem/totem/electron)
Fontconfig warning: "/etc/fonts/fonts.conf", line 86: unknown element "blank"
A JavaScript error occurred in the main process
Uncaught Exception:
Error: The module '/home/totem/totem/resources/app/node_modules/usb/build/Release/usb_bindings.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 72. This version of Node.js requires
NODE_MODULE_VERSION 85. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
at process.func [as dlopen] (electron/js2c/asar_bundle.js:5:1812)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1203:18)
at Object.func [as .node] (electron/js2c/asar_bundle.js:5:1812)
at Module.load (internal/modules/cjs/loader.js:992:32)
at Module._load (internal/modules/cjs/loader.js:885:14)
at Function.f._load (electron/js2c/asar_bundle.js:5:12738)
at Module.require (internal/modules/cjs/loader.js:1032:19)
at require (internal/modules/cjs/helpers.js:72:18)
at bindings (/home/totem/totem/resources/app/node_modules/bindings/bindings.js:112:48)
at Object.<anonymous> (/home/totem/totem/resources/app/node_modules/usb/usb.js:1:57)
What's happening?发生了什么? It's like electron-rebuild did nothing at all.就像电子重建根本没有做任何事情一样。 I can change everything but the operating system and (unless no other solution is available) the fact that i use Electron prebuilt packages instead on $npm install electron .我可以更改除操作系统之外的所有内容,并且(除非没有其他解决方案可用)我使用 Electron 预构建包而不是$npm install electron的事实。 Any idea what's wrong?知道有什么问题吗? Thank you all for your attention.谢谢大家的关注。
You must rebuild any你必须重建任何
npm rebuild
# or
npm install electron-rebuild --save-dev
./node_modules/.bin/electron-rebuild
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.