问题描述
我有一个使用 robotsjs 的电子项目。我正在尝试在 OSX catalina 10.15.7 上使用电子生成器来构建它,但是,在生成分发版本时我遇到了问题。如果我切换到电子锻造,一切正常,但我真的很喜欢电子生成器的所有选项(许可证文件等等)。这是错误:
was compiled against a different Node.js version using
NODE_MODULE_VERSION 72. This version of Node.js requires
NODE_MODULE_VERSION 82. 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.js:140:31)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1196:18)
at Object.func [as .node] (electron/js2c/asar.js:140:31)
at Module.load (internal/modules/cjs/loader.js:981:32)
at Module._load (internal/modules/cjs/loader.js:881:14)
at Function.Module._load (electron/js2c/asar.js:779:28)
at Module.require (internal/modules/cjs/loader.js:1023:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.<anonymous> (/Users/me/Documents/MyElectronApp/node_modules/robotjs/index.js:1:15)
at Module._compile (internal/modules/cjs/loader.js:1145:30)
我看过其他帖子,其中有使用robotjs重建以解决此错误的说明,例如:
1. Run npm i -D electron-rebuild #to add the electron-rebuild package
2. Remove the node-modules folder,as well as the packages-lock.json file.
3. Run npm i to install all modules.
4. Run ./node_modules/.bin/electron-rebuild (.\node_modules\.bin\electron-rebuild.cmd for Windows) to rebuild everything
虽然这在开发模式 (electron-webpack dev
) 下有效,但当我尝试创建分发时它不起作用。启动时生成的应用程序文件也失败并显示上述错误。
我试图将我的构建脚本更改为类似这样的内容来模拟我在开发模式下所做的事情,但我没有得到任何不同的结果。这是我添加的另外两个脚本目标:
"dist": "rm -rf node_modules && rm yarn.lock && yarn install && ./node_modules/.bin/electron-rebuild && electron-builder","simpledist": "electron-rebuild -o robotjs -v 10.3.1"
这是我的依赖项:
"devDependencies": {
"electron": "10.3.1","electron-builder": "^22.9.1","electron-rebuild": "^2.3.4","electron-webpack": "^2.8.2","webpack": "~4.42.1"
},"dependencies": {
"express": "^4.17.1","robotjs": "^0.6.0","source-map-support": "^0.5.19","winston": "^3.3.3"
}
有谁知道我如何让电子构建器构建一个以 robotsjs 作为依赖项的应用程序?谢谢
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)