前提・実現したいこと
electronで画像ビューアを作っています。
electron-builderでポータブルアプリとしてリリースしたいのですが、"~~/app.asar" does not exist というエラーが出てしまいビルドに失敗します。
エラーをなくしたいのですが、どのようにするとよいでしょうか。
ご協力お願いします。
発生している問題・エラーメッセージ
次のエラーが出てビルドに失敗します。
一部抜粋
(node:9104) UnhandledPromiseRejectionWarning: Error: Application entry file "src\main.js" in the "E:\MyProductions\electron\test\dist\win-unpacked\resources\app.asar" does not exist. Seems like a wrong configuration.
エラー全文
D:\electron\test>node src/build-win ・electron-builder version=22.3.2 os=10.0.17763 ・loaded configuration file=package.json ("build" field) ・description is missed in the package.json appPackageFile=D:\electron\test\package.json ・writing effective config file=dist\builder-effective-config.yaml ・packaging platform=win32 arch=x64 electron=8.0.2 appOutDir=dist\win-unpacked (node:9104) UnhandledPromiseRejectionWarning: Error: Application entry file "src\main.js" in the "D:\electron\test\dist\win-unpacked\resources\app.asar" does not exist. Seems like a wrong configuration. at error (D:\electron\test\node_modules\app-builder-lib\src\asar\asarFileChecker.ts:7:12) at checkFileInArchive (D:\electron\test\node_modules\app-builder-lib\src\asar\asarFileChecker.ts:33:11) at WinPackager.checkFileInPackage (D:\electron\test\node_modules\app-builder-lib\src\platformPackager.ts:402:7) at WinPackager.sanityCheckPackage (D:\electron\test\node_modules\app-builder-lib\src\platformPackager.ts:453:5) at WinPackager.doPack (D:\electron\test\node_modules\app-builder-lib\src\platformPackager.ts:242:5) at WinPackager.pack (D:\electron\test\node_modules\app-builder-lib\src\platformPackager.ts:114:5) at Packager.doBuild (D:\electron\test\node_modules\app-builder-lib\src\packager.ts:444:9) at executeFinally (D:\electron\test\node_modules\builder-util\src\promise.ts:12:14) at Packager._build (D:\electron\test\node_modules\app-builder-lib\src\packager.ts:373:31) at Packager.build (D:\electron\test\node_modules\app-builder-lib\src\packager.ts:337:12) at executeFinally (D:\electron\test\node_modules\builder-util\src\promise.ts:12:14) (node:9104) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:9104) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
該当のソースコード
ディレクトリ構成です
directory
1test 2├ node_modules 3│ └ (色々) 4├ pic 5│ └ (.pngや.jpgなど) 6├ src 7│ ├ build-win.js 8│ ├ index.html 9│ ├ main.js 10│ └ package.json 11├ package.json 12└ package-lock.json
ファイルの中身です
js
1// src/build-win.js 2 3const builder = require('electron-builder'); 4builder.build({ 5 config: { 6 'appId': 'test', 7 'win': { 8 'target': 'portable' 9 } 10 } 11}); 12
json
1// src/package.json(←本番環境では記述していません) 2 3{ 4 "name": "test", 5 "version": "1.0.0", 6 "main": "main.js", 7 "dependencies": {} 8}
json
1// package.json(←本番環境では記述していません) 2 3{ 4 "name": "test", 5 "version": "1.0.0", 6 "description": "", 7 "main": "./src/main.js", 8 "dependencies": {}, 9 "scripts": { 10 "test": "echo \"Error: no test specified\" && exit 1", 11 "start": "electron ./src" 12 }, 13 "keywords": [], 14 "author": "", 15 "license": "ISC", 16 "build": { 17 "productName": "test", 18 "appId": "test", 19 "files": [ 20 "pic/" 21 ], 22 "win": { 23 "target": "portable" 24 } 25 }, 26 "devDependencies": { 27 "electron": "^8.0.2", 28 "electron-builder": "^22.3.2" 29 } 30}
補足情報・試したこと
- windows10を使用しています
- testフォルダで次を実行してelectronとelectron-builderをインストールしました
cmd
1npm i -D electron 2npm i -D electron-builder
- testフォルダで次を実行してアプリを起動することはできました
cmd
1npm start
- testフォルダで次を実行してビルドしようとしました
cmd
1node src/build-win
以上です。
ご協力お願いします。
あなたの回答
tips
プレビュー