在打包的Electron应用程序中运行execFileSync时出错 [英] Error while running execFileSync in packaged Electron app

查看:548
本文介绍了在打包的Electron应用程序中运行execFileSync时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过electronic-packager(asar = false)在打包的电子应用程序中运行了以下代码。

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/src/excutable/test.sh

project / main.js

project/main.js

有什么想法吗?

推荐答案

我认为打包后路径可能是错误的。您应该尝试在应用中执行 console.log(app.getAppPath()); (例如,发送至渲染器,写入日志文件等),以进行仔细检查。如果它指向预期的路径。

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.

这篇关于在打包的Electron应用程序中运行execFileSync时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆