I have an electron project using robotjs. I am trying to build it using electron-builder on OSX catalina 10.15.7, however, I am running into issues when it comes to generating a distribution build. If I switch over to electron-forge, everything works fine, but I really like all the options that I get with electron-builder more (license files, and much more). Here is the error:
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)
I have seen other posts where there are instructions to rebuild with robotjs to get around this error, for example this:
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
While this works in dev mode (electron-webpack dev
), it does not work when I try to create a distribution. The generated app files when launched fail with the error above as well.
I have tried to change my build scripts to something like this to simulate what I am doing in dev mode, but I did not get any different results. Here are two additional script targets I added:
"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"
Here are my dependancies:
"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"
}
Does anyone know how I can get electron-builder to build an app with robotjs as a dependency? thank you