Open stepheneb opened 3 years ago
I already have iohook in the package.json dependencies for the electron app so when I manually create the destination path and copy iohook.node
successfully built in the git clone in a separate directory iohook and the application work without error.
I'd like to be able to do this in electron-forge more automatically and build distributable artifacts for Windows and macOS.
This manual process worked:
$ mkdir -p './out/CfA OWN Electron-darwin-x64/CfA OWN Electron.app/Contents/Resources/app/.webpack/main/builds/electron-v89-darwin-x64/build/Release'
$ ls -asl './out/CfA OWN Electron-darwin-x64/CfA OWN Electron.app/Contents/Resources/app/.webpack/main/builds/electron-v89-darwin-x64/build/Release'
total 0
0 drwxr-xr-x 2 stephen staff 64 Oct 31 02:40 .
0 drwxr-xr-x 3 stephen staff 96 Oct 31 02:40 ..
$ ls -l ../iohook/build/Release/iohook.node
-rwxr-xr-x 1 stephen staff 70616 Oct 31 02:14 ../iohook/build/Release/iohook.node
$ cp ../iohook/build/Release/iohook.node './out/CfA OWN Electron-darwin-x64/CfA OWN Electron.app/Contents/Resources/app/.webpack/main/builds/electron-v89-darwin-x64/build/Release'
$ ls -l './out/CfA OWN Electron-darwin-x64/CfA OWN Electron.app/Contents/Resources/app/.webpack/main/builds/electron-v89-darwin-x64/build/Release'
144 -rwxr-xr-x 1 stephen staff 70616 Oct 31 02:41 iohook.node
When you do npm install iohook
only the essential "prod" part of the library is installed inside node_modules/iohook
. When you clone the iohook repo you get the complete library source with everything needed to manually build. You could for convenience move the entire dev repo into node_modules/iohook
and build from there, but then you'd have a lot of unnecessary junk packaged with your electron app unless you add exceptions to your Forge config to exclude them. The easiest thing to do in this situation IMHO is to have your separate iohook clone folder where you do your manual build, then copy your build files .node and .dylib into e.g. [your electron app source]/node_modules/iohook/builds/electron-v89-darwin-x64/buildRelease/
and then Forge will automatically include those in your packaged app.
environment: os: macOs 11.6.1
I can clone iohook to a stand alone directory and successfully build with this command:
gyp ends with an ok and this file is generated:
So I tried an equivalent series of commands to do this in my electron applications
node_modules
directory:Which fails with this error:
Here's the console log: