electron-builder 打包create-react-app出现Not allowed to load 错误
项目地址:https://github.com/yourenA/t-...
使用electron-builder 打包create-react-app出现 Not allowed to load local resource: file:///C:/Program%20Files%20(x86)/t-box-tester/resources/app.asar/build/build/index.html
错误。
package.json部分代码
"main": "public/electron.js", //在public目录下
"homepage": "./",
"repository": "https://github.com/electron/electron-quick-start",
"author": "GitHub",
"build": {
"publish": [
{
"provider": "generic",
"url": "http://localhost:4000/electron/"
}
],
"directories": {
"output": "release",
"app": "./"
},
"files": [
"./build/**/*",
"./public/electron.js",
"./package.json"
],
"win": {
"target": [
"nsis",
"zip"
]
},
"nsis": {
"oneClick": false,
"allowToChangeInstallationDirectory": true,
"perMachine": true
}
},
"scripts": {
"dev": "concurrently \"set BROWSER=none&&react-scripts start\" \"wait-on http://localhost:3000 && electron .\"",
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"dist": "electron-builder"
},
electron.js中加载window代码
if (isDev) {
mainWindow.loadURL("http://localhost:3000/");
} else {
mainWindow.loadURL(`file://${path.join(__dirname,'./../build/index.html')}`);
}
使用npm run dev
在开发模式下可以正常打开程序。
使用npm run dist
打包安装exe后,打开程序报Not allowed to load local resource: file:///C:/Program%20Files%20(x86)/t-box-tester/resources/app.asar/build/build/index.html
错误。
原因可能是create-react-app打包后的文件build文件我的electron.js中加载window代码错误或者我的package.json中files配置错误
请问一下各位该怎么解决这个问题?谢谢!
项目地址:https://github.com/yourenA/t-...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
file:///C:/Program%20Files%20(x86)/t-box-tester/resources/app.asar/build/build/index.html
这个路径里有两个
build
,你确定这个路径没有问题吗?