[英]No native build was found for platform=darwin arch=arm64 runtime=electron abi=103
[英]Local native Node module causes error: Uncaught Error: No native build was found for platform=win32 arch=x64 runtime=electron abi=75 uv=1 libc=glibc
我有一个我写的本机 Node 插件,我正在尝试添加到一个 Electron 应用程序中。 我使用npm install /path/to/addon
来安装插件。 然后electron-rebuild
和electron-build
,它们不会抱怨。
但是当我运行npm start
,在开发控制台中出现以下错误:
Uncaught Error: No native build was found for platform=win32 arch=x64 runtime=electron abi=75 uv=1 libc=glibc
at Function.load.path (C:\path\to\node_modules\node-gyp-build\index.js:55:9)
at load (C:\path\to\node_modules\node-gyp-build\index.js:20:30)
at Object.<anonymous> (C:\path\to\index.js:2:42)
at Object.<anonymous> (C:\path\to\index.js:27:3)
at Module._compile (internal/modules/cjs/loader.js:880:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:892:10)
at Module.load (internal/modules/cjs/loader.js:735:32)
at Module._load (internal/modules/cjs/loader.js:648:12)
at Module._load (electron/js2c/asar.js:717:26)
at Function.Module._load (electron/js2c/asar.js:717:26)
我在网上找不到关于此错误的太多信息。 我尝试重新编译所有内容,尝试使用 Electron 作为目标重建插件,但没有任何帮助。 为什么会发生此错误,我该如何补救?
错误是一个愚蠢的错误。 在 index.js 中,我在做
let addon= require("node-gyp-build")("./");
本质上, "./"
在与 npm 一起安装时不会正确链接,因为./
是当前项目的根目录,而不是安装的根目录。 __dirname
将正确链接插件
let addon= require("node-gyp-build")(__dirname);
注意:我也改用了prebuildify ,这意味着我不再需要运行 npm electron-builder
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.