【发布时间】:2019-12-28 12:01:31
【问题描述】:
我正在合作开发一个使用本机模块(串行端口)的 VSCode 扩展。 为了使解决方案在所有平台上稳定运行,并且随着 VScode 更改电子版本而随时间推移,我想包含预构建的原生模块。
现在看来,这些预编译模块中的一些(不是全部)不是他们声称的版本。
为了测试/验证,我想以编程方式确定 ABI 版本,如果可能的话,为 install-prebuild 下载的每个本机模块确定运行时、平台(darwin、linux、win32)和架构
即当我尝试在电子 5.0.10 (ABI-70) 中加载模块时引发以下错误:
Uncaught Error: The module '\\?\C:\develop\NodeJS\electron-serialport\node_modules\@serialport\bindings\lib\binding\node-v70-win32-x64\bindings.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 47. This version of Node.js requires
NODE_MODULE_VERSION 70. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
所以它在下载时报告 ABI 47,通过 prebuild-install 下载为 ABI 70。 注意:将电子绑定存储在节点绑定位置以允许“绑定”检测 ABI、平台和架构
## npx prebuild-install
Download prebuild native binding for runtime electron : 5.0.5, abi: 70, win32, x64
prebuild-install info begin Prebuild-install version 5.3.0
prebuild-install info looking for cached prebuild @ C:\Users\josverl\AppData\Roaming\npm-cache\_prebuilds\bde028-bindings-v2.0.8-electron-v70-win32-x64.tar.gz
prebuild-install info found cached prebuild
prebuild-install info unpacking @ C:\Users\josverl\AppData\Roaming\npm-cache\_prebuilds\bde028-bindings-v2.0.8-electron-v70-win32-x64.tar.gz
prebuild-install info unpack resolved to C:\develop\NodeJS\electron-serialport\node_modules\@serialport\bindings\build\Release\bindings.node
prebuild-install info install Successfully installed prebuilt binary!
Copy to :
-> C:\develop\NodeJS\electron-serialport\noded_modules\@serialport\bindings\lib\binding\node-v70-win32-x64\bindings.node
【问题讨论】:
标签: node.js visual-studio-code electron vscode-extensions node-serialport