问题
I ran the following code in packaged electron app by electron-packager(asar=false).
const app = require(‘electron’);
const { join } = require(‘path’);
const EXEC_OPTS = {encoding: 'utf-8', shell: true};
childProcess.execFileSync(join(app.getAppPath(), 'src', 'executable') + ‘/test.sh’, [''], EXEC_OPTS);
But I got nothing even error logs..
This code normally can run only by command of “electron .” , But this code cannot run after packaging by electron packager .
Structure is like this (just wrote necessary part. )
project/src/excutable/test.sh
project/main.js
Any idea?
回答1:
I think the path could be wrong after packaging. You should try to do a console.log(app.getAppPath());
(e.g. send to renderer, write to a log file etc.) in your app to double check if it is pointing to the expected path.
来源:https://stackoverflow.com/questions/50693947/error-while-running-execfilesync-in-packaged-electron-app