1

I am developing an electron app with react and I have a python file which I want to run through main process of electron.

I am using child-process of node js to spawn the python exe(esic.exe) file. I created the python exe file using pyinstaller which runs fine in standalone mode.

const exeLocation = path.join(__dirname, 'dist/esic.exe')
const process = spawn(exeLocation, [args])

In development mode everything runs properly, main process of electron could able to spawn the process and send arguments and receive the output, but once I package the electron app using electron-builder it gives me this ENOENT code error enter image description here

I searched about ENOENT error and found that it's the error which indicates that the specified path for a file or directory does not exist in the filesystem so I tried to unpackage the electron build which has a app.asar file. On unpackaging the asar file I found that it contains the dist directory and there is a esic.exe file in it, so that means the electron-builder packaged the build correctly.

Now I am totally confused about why it runs in development mode but not in production mode.

2 Answers 2

0

Place the exe file outside the app.asar and set the third parameter of spawn to {shell: true}.

Sign up to request clarification or add additional context in comments.

Comments

0

keep this exe outside asar. give its absolute path to spawn. like this

if (app.isPackaged) {
    workerPath = path.join(
      path.dirname(app.getPath("exe")),
      "resources",
      "bin",
      "esic.exe"
    );
  } else {
    workerPath = path.join(__dirname, "..", "bin", "esic.exe");
  }

in package.js build section add

"extraResources": [
      {
        "from": "bin/",
        "to": "bin/",
        "filter": [
          "**/*"
        ]
      }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.