Emr*_*nce 6 javascript reactjs electron electron-builder
我在使用电子生成器时遇到问题我在控制台中有空白页面和错误:
Not allowed to load local resource: file:///C:/Users/emretekince/Desktop/DCSLogBook/client/dist/win-unpacked/resources/app.asar/build/index.html
Run Code Online (Sandbox Code Playgroud)
main.js
const startUrl = process.env.ELECTRON_START_URL || url.format({
pathname: path.join(__dirname, '/build/index.html'),
protocol: 'file:',
slashes: true
});
mainWindow.loadURL(startUrl);
Run Code Online (Sandbox Code Playgroud)
通过在package.json中添加"files"解决
"files": [
"*.js",
"build",
"node_modules"
],
Run Code Online (Sandbox Code Playgroud)
我认为您的 index.html 文件不存在于您的给定位置。 __dirname, '/build/index.html'
我错过了这个愚蠢的点,浪费了很多时间。Angular-cli 在 dist 的文件夹中为 index.html 创建默认位置。
dist/project-name/index.html
Run Code Online (Sandbox Code Playgroud)
小智 5
我一整天都在尝试解决这个问题,终于找到了解决方案,
"build": {
"appId": "myledgerapp",
"extends": null,
"files": [
"./build/**/*",
"./public/electron.js"
]}
Run Code Online (Sandbox Code Playgroud)
我们需要在构建部分添加文件,其中 electro.js 是我的入口点。
| 归档时间: |
|
| 查看次数: |
9258 次 |
| 最近记录: |