Search code examples
node.jselectronelectron-packager

Cannot execute shell command from Electron packaged app


I have my Electron app which I am packaging with electron-packager npm module. I want to execute an python application only by name from Nodejs module called child_process. When the application isn't packaged it works, but when I package it does not work. I noticed that the packaged app does not load PATH variable so it works only if I change it to absolute path to the script. But I want to make it platform independent, so it is not a solution for me.

Is there any way how can I "inject" PATH variable to the packaged application or any other solution?


Solution

  • This is probably this PATH issue.

    And you can fix it with this package.

    const fixPath = require('fix-path');
    
    fixPath();
    
    console.log(process.env.PATH);
    //=> '/usr/local/bin:/usr/bin'