我有一个 Electron 应用程序.我尝试让应用程序打开一个 .exe 文件.我在名为 lib 的根文件夹中创建了一个目录,并将 .exe 文件放在那里.在开发中,我使用 __dirname + '/lib/file.exe 打开文件没有问题,但是当我打包应用程序时(使用 yarn dist),它确实不打开exe文件,dist文件夹下也没有lib文件夹了.
I have an Electron app. I try to make the app open an .exe file. I created a directory in the root folder named lib and placed the .exe file there. In development, I have no problem opening the file by using __dirname + '/lib/file.exe, but when I package the app (using yarn dist), it does not open the exe file and there is no lib folder anymore on the dist folder.
我尝试使用 console.log(__dirname) 写入控制台默认位置,它输出 distwin-unpacked
esourcesapp.asa (即一个文件).
I tried writing to console the default location using console.log(__dirname) and it outputs distwin-unpacked
esourcesapp.asa (which is a file).
如何添加应用打包时可以访问的外部文件?
How can I add an external file that can be accessed when the app is packaged?
设法通过使用 extraResources 来解决它.应该在 package.json 文件中的 build 下声明.
Managed to solve it by using extraResources. Should be declared under build in your package.json file.
例如:
将以下代码添加到您的 package.json 文件中:
<代码>构建":{"extraResources": ["./extraResources/**"]}
这篇关于Electron - 如何添加外部文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
discord.js v12:我如何等待 DM 频道中的消息?discord.js v12: How do I await for messages in a DM channel?(discord.js v12:我如何等待 DM 频道中的消息?)
如何让我的机器人提及发出该机器人命令的人how to make my bot mention the person who gave that bot command(如何让我的机器人提及发出该机器人命令的人)
如何修复必须使用导入来加载 ES 模块 discord.jsHow to fix Must use import to load ES Module discord.js(如何修复必须使用导入来加载 ES 模块 discord.js)
如何列出来自特定服务器的所有成员?How to list all members from a specific server?(如何列出来自特定服务器的所有成员?)
Discord bot:修复“找不到 FFMPEG"Discord bot: Fix ‘FFMPEG not found’(Discord bot:修复“找不到 FFMPEG)
使用 discord.js 加入 discord 服务器时的欢迎消息Welcome message when joining discord Server using discord.js(使用 discord.js 加入 discord 服务器时的欢迎消息)