Packaging and running a precompiled (go) binary?


Hi everyone. I’ve read and googled but I can’t seem to find a good answer to this question.

I’m just getting started with Electron+Vue (using and I need to include a precompiled Go binary with my Electron app, which will be started on app open, and killed on close. I’ve managed to get it working using yarn run dev by pointing to the binary file explicitly with execFile:

child_process.execFile('/path/mybinary/file', ['--port', 8100], function(error, stdout, stderr){});

However, for the life of me I can’t figure out how to make this work when the app is packaged.

My suspicion is that the binary file is not being included in the package, since when I run the packaged app using open build/mac/ I log an error: Error: spawn /path/mybinary/file ENOENT ...

So I suppose my question is - how do I get my binary included in the package, and where do I put it?



I’ve figured out how to add the binary to the package by adding it to the electron-vue Static folder. However, now I have spawn EACCES at ChildProcess.spawn.

Clearly I’m missing something stupid and obvious, perhaps someone more experienced can point me in the right direction?


Updating this for any poor souls who come looking with the same or similar problem. I have solved it by doing the following:

  • Placed my binary file in project/static/bin/binaryfile (static is special for electron-vue)
  • Moved the file using the extraResources parameter of the build section of package.json:
    •  {
        "from": "./static/bin/",
        "to": "api/bin/",
         "filter": [
  • In index.js, use a different path for dev and production, as per this comment:
     filepath = path.join(__dirname, "myscripts/");
} else {
     filepath = path.join(process.resourcesPath, "app/myfolder/subfolder/myscripts/");
// And then use execFile on filepath.

I’m not sure if this is the best solution, but it appears to work in both dev and packaged builds.