我正在尝试使用 ElectronJs 为树莓派 3 (b) 构建一个应用程序。我无法使用nodejs的“onoff”模块与树莓派的GPIO进行通信。当我将其导入主进程并尝试使用
electron .
命令运行应用程序时,该命令退出且没有错误信息。谁能建议如何在电子应用程序中使用树莓派3的GPIO。
另外,如果 ElectronJs 无法实现,那么请建议我如何为树莓派实现一个可以使用 GPIO 的 GUI 应用程序。
将nodeJS更新到最新版本并运行electron-rebuild解决了我的问题。谢谢戴夫·牛顿的帮助。似乎 onoff 包使用的 epoll 编译存在问题。
你能解释一下更多吗?,我也犯了同样的错误
A JavaScript error occurred in the main process
Uncaught Exception:
Error: The module '/home/ti/Documentos/teste/node_modules/epoll/build/Release/epoll.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 115. This version of Node.js requires
NODE_MODULE_VERSION 116. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
at process.func [as dlopen] (node:electron/js2c/asar_bundle:2:1822)
at Object.<anonymous> (node:internal/modules/cjs/loader:1356:18)
at Object.func [as .node] (node:electron/js2c/asar_bundle:2:1822)
at Module.load (node:internal/modules/cjs/loader:1126:32)
at node:internal/modules/cjs/loader:967:12
at Function._load (node:electron/js2c/asar_bundle:2:13330)
at Module.require (node:internal/modules/cjs/loader:1150:19)
at require (node:internal/modules/cjs/helpers:110:18)
at bindings (/home/ti/Documentos/teste/node_modules/bindings/bindings.js:112:48)
at /home/ti/Documentos/teste/node_modules/epoll/epoll.js:7:31