我刚刚创建了电子反应应用程序,还实现了自动更新功能。但出乎意料的是,我从电子生成器那里得到了一些奇怪的错误日志。
我不知道该怎么解决。我试过不同的方法。我希望这个社区能帮助我。提前谢谢。
此配置适用于开发本地构建,并且在安装后也可以按预期正常工作。该问题只会引发npm run package-deploy
命令。
我做错什么了吗?
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"
}
}
错误日志
> analyzer@1.2.1 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=distbuilder-effective-config.yaml
• packaging platform=win32 arch=x64 electron=12.0.8 appOutDir=distwin-unpacked
• building target=nsis file=distStock Analyzer Setup 1.2.1.exe archs=x64 oneClick=true perMachine=false
• building block map blockMapFile=distStock 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:UsersMDDesktopstock-calcnode_moduleselectron-publishsrcgitHubPublisher.ts:190:36)
at GitHubPublisher.doUpload (C:UsersMDDesktopstock-calcnode_moduleselectron-publishsrcgitHubPublisher.ts:170:23)
at processTicksAndRejections (node:internal/process/task_queues:94:5)
at GitHubPublisher.upload (C:UsersMDDesktopstock-calcnode_moduleselectron-publishsrcpublisher.ts:87:5)
at async Promise.all (index 2)
at AsyncTaskManager.awaitTasks (C:UsersMDDesktopstock-calcnode_modulesbuilder-utilsrcasyncTaskManager.ts:65:25)
at PublishManager.awaitTasks (C:UsersMDDesktopstock-calcnode_modulesapp-builder-libsrcpublishPublishManager.ts:228:5)
at Object.executeFinally (C:UsersMDDesktopstock-calcnode_modulesbuilder-utilsrcpromise.ts:23:3)
Error #2 --------------------------------------------------------------------------------
TypeError: Cannot read property 'getType' of undefined
at GitHubPublisher.doUploadFile (C:UsersMDDesktopstock-calcnode_moduleselectron-publishsrcgitHubPublisher.ts:190:36)
at GitHubPublisher.doUpload (C:UsersMDDesktopstock-calcnode_moduleselectron-publishsrcgitHubPublisher.ts:170:23)
at processTicksAndRejections (node:internal/process/task_queues:94:5)
at GitHubPublisher.upload (C:UsersMDDesktopstock-calcnode_moduleselectron-publishsrcpublisher.ts:87:5)
at async Promise.all (index 3)
at AsyncTaskManager.awaitTasks (C:UsersMDDesktopstock-calcnode_modulesbuilder-utilsrcasyncTaskManager.ts:65:25)
at PublishManager.awaitTasks (C:UsersMDDesktopstock-calcnode_modulesapp-builder-libsrcpublishPublishManager.ts:228:5)
at Object.executeFinally (C:UsersMDDesktopstock-calcnode_modulesbuilder-utilsrcpromise.ts:23:3) failedTask=build stackTrace=Error: Cannot cleanup
万岁!我自己解决了这个问题。感谢我自己。这是我的案子的解决方案。我希望它将来能帮助到别人。
- 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": {
"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"
}
}
删除->package.lock.json.
删除->节点模块。
键入
npm install
。为该特定回购生成GitHub个人访问令牌。(就我而言,这是一笔私人回购)注意:访问令牌应获得repo的权限。
为访问令牌设置GH_TOKEN的env值。
- 打开PowerShell,然后键入
[Environment]::SetEnvironmentVariable("GH_TOKEN","<TOKEN>","User")
运行部署命令
npm run package-deploy
。
就是这样!快乐的编码。