Error while running execFileSync in packaged Electron app

扶醉桌前 提交于 2019-12-13 03:04:47

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!