I just created my electron-react application and also I implemented the auto-update functionality. But unexpectedly I got some weird error logs from electron-builder.
I'm not sure how to resolve it. I tried different kinds of ways. I hope this community helps me. Thanks in advance.
This configuration works fine for developing local build and also after installed it's works fine as per expected. The problem only raises the npm run package-deploy
command.
Am I doing anything wrong?
package.json
{
"name": "analyzer",
"version": "1.2.1",
"private": true,
"homepage": "./",
"author": "Mohamed Jakkariya",
"description": "This application used for analyzing the stock information and find useful data for trading in the better way.",
"dependencies": {
"@material-ui/core": "^4.11.4",
"@material-ui/icons": "^4.11.2",
"@material-ui/lab": "*",
"@reduxjs/toolkit": "^1.5.1",
"csv-parser": "^3.0.0",
"electron-is-dev": "^2.0.0",
"electron-updater": "^4.3.9",
"moment": "^2.29.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-redux": "^7.2.4",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.3",
"styled-components": "^5.3.0"
},
"scripts": {
"start": "set BROWSER=none && react-scripts start",
"electron": "electron .",
"start-electron": "set ELECTRON_START_URL=http://localhost:3000 && electron .",
"test": "react-scripts test",
"eject": "react-scripts eject",
"build": "react-scripts build",
"build-electron": "robocopy src/electron build/electron /S ",
"lint": "eslint src/**/*.js src/**/*.jsx",
"package-build": "electron-builder build --win -c.extraMetadata.main=build/electron.js --publish never",
"package-deploy": "electron-builder build --win -c.extraMetadata.main=build/electron.js --publish always"
},
"main": "public/electron.js",
"publish": {
"provider": "github",
"repo": "nift-analyzer",
"owner": "MohamedJakkariya",
"releaseType": "release"
},
"repository": {
"type": "git",
"url": "https://github.com/MohamedJakkariya/nift-analyzer/"
},
"build": {
"productName": "Stock Analyzer",
"appId": "com.mohamedjakkariya.nift-analyzer",
"files": [
"build/**/*",
"node_modules/**/*"
],
"win": {
"icon": "./public/icon.png",
"publish": [
"github"
]
},
"directories": {
"buildResources": "assets"
}
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"electron": "^12.0.8",
"electron-builder": "^22.11.1",
"electron-devtools-installer": "^3.2.0",
"eslint-plugin-react": "^7.23.2"
}
}
Error Logs
> [email protected] package-deploy
> electron-builder build --win -c.extraMetadata.main=build/electron.js --publish always
• electron-builder version=22.10.5 os=10.0.18362
• cannot check updates error=TypeError: update_notifier_1.default is not a function
• loaded configuration file=package.json ("build" field)
• loaded parent configuration preset=react-cra
• writing effective config file=dist\builder-effective-config.yaml
• packaging platform=win32 arch=x64 electron=12.0.8 appOutDir=dist\win-unpacked
• building target=nsis file=dist\Stock Analyzer Setup 1.2.1.exe archs=x64 oneClick=true perMachine=false
• building block map blockMapFile=dist\Stock Analyzer Setup 1.2.1.exe.blockmap
• publishing publisher=Github (owner: MohamedJakkariya, project: nift-analyzer, version: 1.2.1)
• uploading file=Stock-Analyzer-Setup-1.2.1.exe.blockmap provider=GitHub
• uploading file=Stock-Analyzer-Setup-1.2.1.exe provider=GitHub
⨯ Cannot cleanup:
Error #1 --------------------------------------------------------------------------------
TypeError: Cannot read property 'getType' of undefined
at GitHubPublisher.doUploadFile (C:\Users\MD\Desktop\stock-calc\node_modules\electron-publish\src\gitHubPublisher.ts:190:36)
at GitHubPublisher.doUpload (C:\Users\MD\Desktop\stock-calc\node_modules\electron-publish\src\gitHubPublisher.ts:170:23)
at processTicksAndRejections (node:internal/process/task_queues:94:5)
at GitHubPublisher.upload (C:\Users\MD\Desktop\stock-calc\node_modules\electron-publish\src\publisher.ts:87:5)
at async Promise.all (index 2)
at AsyncTaskManager.awaitTasks (C:\Users\MD\Desktop\stock-calc\node_modules\builder-util\src\asyncTaskManager.ts:65:25)
at PublishManager.awaitTasks (C:\Users\MD\Desktop\stock-calc\node_modules\app-builder-lib\src\publish\PublishManager.ts:228:5)
at Object.executeFinally (C:\Users\MD\Desktop\stock-calc\node_modules\builder-util\src\promise.ts:23:3)
Error #2 --------------------------------------------------------------------------------
TypeError: Cannot read property 'getType' of undefined
at GitHubPublisher.doUploadFile (C:\Users\MD\Desktop\stock-calc\node_modules\electron-publish\src\gitHubPublisher.ts:190:36)
at GitHubPublisher.doUpload (C:\Users\MD\Desktop\stock-calc\node_modules\electron-publish\src\gitHubPublisher.ts:170:23)
at processTicksAndRejections (node:internal/process/task_queues:94:5)
at GitHubPublisher.upload (C:\Users\MD\Desktop\stock-calc\node_modules\electron-publish\src\publisher.ts:87:5)
at async Promise.all (index 3)
at AsyncTaskManager.awaitTasks (C:\Users\MD\Desktop\stock-calc\node_modules\builder-util\src\asyncTaskManager.ts:65:25)
at PublishManager.awaitTasks (C:\Users\MD\Desktop\stock-calc\node_modules\app-builder-lib\src\publish\PublishManager.ts:228:5)
at Object.executeFinally (C:\Users\MD\Desktop\stock-calc\node_modules\builder-util\src\promise.ts:23:3) failedTask=build stackTrace=Error: Cannot cleanup
Hurray! I fixed the issue myself. Thanks to myself. Here, it's the solution for my case. I hope it'll help someone in the future.
{
"name": "analyzer",
"version": "1.2.1",
"private": true,
"homepage": "./",
"author": "Mohamed Jakkariya",
"description": "This application used for analyzing the stock information and find useful data for trading in the better way.",
"dependencies": {
"electron-is-dev": "^2.0.0",
"electron-updater": "^4.3.9",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.3"
},
"scripts": {
"start": "set BROWSER=none && react-scripts start",
"electron": "electron .",
"start-electron": "set ELECTRON_START_URL=http://localhost:3000 && electron .",
"test": "react-scripts test",
"eject": "react-scripts eject",
"build": "react-scripts build",
"build-electron": "robocopy src/electron build/electron /S ",
"lint": "eslint src/**/*.js src/**/*.jsx",
"package-build": "electron-builder build --win -p never",
"package-deploy": "electron-builder build --win -p always"
},
"main": "public/electron.js",
"repository": {
"type": "git",
"url": "https://github.com/MohamedJakkariya/nift-analyzer.git"
},
"build": {
"publish": [
{
"provider": "github",
"owner": "MohamedJakkariya",
"repo": "nift-analyzer"
}
],
"productName": "Stock Analyzer",
"appId": "com.mohamedjakkariya.nift-analyzer",
"files": [
"build/**/*",
"node_modules/**/*"
],
"win": {
"icon": "./public/icon.png",
"publish": [
"github"
]
},
"directories": {
"buildResources": "assets"
}
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"electron": "^12.0.8",
"electron-builder": "^22.11.1",
"electron-devtools-installer": "^3.2.0",
"eslint-plugin-react": "^7.23.2"
}
}
Remove -> package.lock.json.
Remove -> node_modules.
Type npm install
.
Generate GitHub personal access token for that particular repo. (For my case it's a private repo) Note: Access token should be given the permission of repo.
Set env value of GH_TOKEN for an access token.
[Environment]::SetEnvironmentVariable("GH_TOKEN","<TOKEN>","User")
Run deploy command npm run package-deploy
.
That's it! Happy coding. 🎉💖