I am trying to package my Electron application by using electron-builder. But somehow after succesfully built, When run the application and it only showed the white blank scree. Then when check the console, there is an error like below, is it a problem cause by the build itself or come from the package.json, or from my directory. any hint ? Thankyou
, Already tried many solution on the stack overflow and other place but not fixing the problem so I decided to add question.
I also attached my
package.json
{
"name": "cookbook-dekstop",
"version": "1.0.0",
"description": "",
"main": "main.js",
"homepage": "./",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"watch": "webpack --config webpack.common.js --watch",
"start": "electron .",
"build": "electron-builder"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^6.2.0",
"@fortawesome/free-regular-svg-icons": "^6.2.0",
"@fortawesome/free-solid-svg-icons": "^6.2.0",
"@fortawesome/react-fontawesome": "^0.2.0",
"axios": "^0.27.2",
"babel-preset-es2015": "^6.24.1",
"downloadjs": "^1.4.7",
"file-loader": "^6.2.0",
"html-to-image": "^1.10.8",
"html2canvas": "^1.4.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.3.0",
"url-loader": "^4.1.1"
},
"devDependencies": {
"@babel/core": "^7.18.13",
"@babel/preset-env": "^7.18.10",
"@babel/preset-react": "^7.18.6",
"autoprefixer": "^10.4.8",
"babel-loader": "^8.2.5",
"css-loader": "^6.7.1",
"electron": "^20.1.1",
"electron-reload": "^2.0.0-alpha.1",
"postcss": "^8.4.16",
"sass": "^1.54.8",
"sass-loader": "^13.0.2",
"style-loader": "^3.3.1",
"tailwindcss": "^3.1.8",
"webpack": "^5.74.0",
"webpack-cli": "^4.10.0"
},
"build": {
"appId": "cookbook-dekstop",
"icon": "src/assets/cb.ico",
"directories": {
"output": "dist"
},
"extraFiles": [
"./dist/assets/**"
],
"files": [
"./dist/**/*",
"main.js",
"preload.js"
],
"linux": {
"target": [
"deb"
]
},
"mac": {
"target": [
{
"target": "dmg",
"arch": [
"x64"
]
}
]
},
"win": {
"target": [
"portable"
]
}
}
}
main.js
var win = new BrowserWindow({
width: 600,
height: 800,
backgroundColor: "white",
icon: "./src/assets/cb.ico",
webPreferences: {
nodeIntegration: false,
worldSafeExecuteJavaScript: true,
contextIsolation: true,
preload: path.join(__dirname, "preload.js"),
},
resizable: false,
});
win.loadURL(`file://${__dirname}/dist/index.html`);
