无法为 Electron 构建 .exe
Posted
技术标签:
【中文标题】无法为 Electron 构建 .exe【英文标题】:Unable to build .exe for Electron 【发布时间】:2019-11-24 06:57:03 【问题描述】:我正在尝试使用 electron-installer-windows 为我的 Windows 反应网络应用程序创建 .exe。它说
错误:未提供描述或产品描述。请在应用程序的 package.json 中设置描述或在 this.options 中提供。
当我运行npm run setup
时。请找到 packge.json 和错误堆栈跟踪。
package.json
"name": "utility-core",
"description": "Load bulk data to Fluent",
"productDescription":"Test",
"version": "0.0.1",
"license": "ISC",
"productName": "Fluent Bulk Import Utility",
"author":
"name": "Zain Ul Abideen"
,
"private": true,
"main": "public/electron.js",
"homepage": "./",
"dependencies":
"autoprefixer": "7.1.6",
"axios": "^0.18.0",
"babel-core": "6.26.0",
"babel-eslint": "7.2.3",
"babel-jest": "20.0.3",
"babel-loader": "7.1.2",
"babel-preset-react-app": "^3.1.1",
"babel-runtime": "6.26.0",
"bootstrap": "^4.1.3",
"case-sensitive-paths-webpack-plugin": "2.1.1",
"chalk": "1.1.3",
"concurrently": "^4.1.1",
"css-loader": "0.28.7",
"dotenv": "4.0.0",
"dotenv-expand": "4.2.0",
"electron-is-dev": "^1.1.0",
"eslint": "4.10.0",
"eslint-config-react-app": "^2.1.0",
"eslint-loader": "1.9.0",
"eslint-plugin-flowtype": "2.39.1",
"eslint-plugin-import": "2.8.0",
"eslint-plugin-jsx-a11y": "5.1.1",
"eslint-plugin-react": "7.4.0",
"extract-text-webpack-plugin": "3.0.2",
"file-loader": "1.1.5",
"fs-extra": "3.0.1",
"html-webpack-plugin": "2.29.0",
"jest": "20.0.4",
"jquery": "^3.4.1",
"mdbreact": "^4.15.0",
"object-assign": "4.1.1",
"papaparse": "^4.6.0",
"postcss-flexbugs-fixes": "3.2.0",
"postcss-loader": "2.0.8",
"promise": "8.0.1",
"raf": "3.4.0",
"react": "^16.4.1",
"react-dev-utils": "^5.0.1",
"react-dom": "^16.4.1",
"react-file-reader": "^1.1.4",
"react-router-dom": "^4.2.0",
"react-spinners": "^0.4.6",
"resolve": "1.6.0",
"style-loader": "0.19.0",
"sw-precache-webpack-plugin": "0.11.4",
"universal-cookie": "^3.0.4",
"url-loader": "0.6.2",
"wait-on": "^3.2.0",
"webpack": "3.8.1",
"webpack-dev-server": "2.9.4",
"webpack-manifest-plugin": "1.3.2",
"whatwg-fetch": "2.0.3"
,
"scripts":
"start": "node scripts/start.js",
"build": "node scripts/build.js",
"test": "node scripts/test.js --env=jsdom",
"electron-dev": "concurrently \" cross-env BROWSER=none npm run start\" \"wait-on http://localhost:3000 && electron .\"",
"electron-pack": "build -c.extraMetadata.main=build/electron.js",
"preelectron-pack": "npm run build",
"setup": "electron-installer-windows --src dist/fluent-bulk-import-utility-win32-x64/ --dest installers/"
,
"devDependencies":
"cross-env": "^5.2.0",
"csv-loader": "^3.0.2",
"electron": "^1.8.8",
"electron-builder": "^20.44.4",
"electron-installer-windows": "^2.0.0",
"electron-packager": "^8.7.2"
,
"jest":
"collectCoverageFrom": [
"src/**/*.js,jsx,mjs"
],
"setupFiles": [
"<rootDir>/config/polyfills.js"
],
"testMatch": [
"<rootDir>/src/**/__tests__/**/*.js,jsx,mjs",
"<rootDir>/src/**/?(*.)(spec|test).js,jsx,mjs"
],
"testEnvironment": "node",
"testURL": "http://localhost",
"transform":
"^.+\\.(js|jsx|mjs)$": "<rootDir>/node_modules/babel-jest",
"^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
"^(?!.*\\.(js|jsx|mjs|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
,
"transformIgnorePatterns": [
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs)$"
],
"moduleNameMapper":
"^react-native$": "react-native-web"
,
"moduleFileExtensions": [
"web.js",
"js",
"json",
"web.jsx",
"jsx",
"node",
"mjs"
]
,
"babel":
"presets": [
"env",
"react-app"
],
"plugins": []
,
"eslintConfig":
"extends": "react-app"
,
"build":
"extends": null,
"appId": "com.example.utility-core",
"files": [
"build/**/*",
"node_modules/**/*",
"./public/electron.js"
],
"directories":
"buildResources": "assets"
错误堆栈
Error: No Description or ProductDescription provided. Please set either a description in the app's package.json or provide it in the this.options.
at SquirrelInstaller.generateOptions (C:\Users\HP\AppData\Roaming\npm\node_modules\electron-installer-windows\src\installer.js:156:13)
at module.exports (C:\Users\HP\AppData\Roaming\npm\node_modules\electron-installer-windows\src\installer.js:241:19) Error: No Description or ProductDescription provided. Please set either a description in the app's package.json or provide it in the this.options.
at SquirrelInstaller.generateOptions (C:\Users\HP\AppData\Roaming\npm\node_modules\electron-installer-windows\src\installer.js:156:13)
at module.exports (C:\Users\HP\AppData\Roaming\npm\node_modules\electron-installer-windows\src\installer.js:241:19)
主要有以下文件:
https://www.christianengvall.se/electron-windows-installer/
https://www.npmjs.com/package/electron-installer-windows
【问题讨论】:
【参考方案1】:错误所指的“作者”是 electron/package.json 中未定义的作者
确保在构建安装程序之前以及在 electron/package.json 中定义作者之后重新打包
我还建议使用 electron-builder 这里的配置链接 https://www.electron.build/configuration/configuration
【讨论】:
以上是关于无法为 Electron 构建 .exe的主要内容,如果未能解决你的问题,请参考以下文章
构建和运行 vscode 源代码时无法成功 require('electron')
Electron VueJS - 构建错误 - 无法注册应用程序协议。在 app.asar 中找不到 ENOENT、\dist_electron\bundled
Electron 和 TypeScript:“fs”无法解析
使用 Vue CLI Plugin Electron Builder 构建电子应用程序(在初始化之前无法访问“fa”)-TypeORM 关联 ManyToOne