Error while running execFileSync in packaged Elect

2019-08-28 01:37发布

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条回答
混吃等死
2楼-- · 2019-08-28 02:39

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.

查看更多
登录 后发表回答