Electron打包错误“Error: Application entry file ..”解决方案

xiaohai 2021-05-26 18:43:08 14496人围观 标签: Electron 
简介打包出现如下错误:Error: Application entry file "dist\electron\main.js" in the "D:\gui\demo2\build\win-unpacked\resources\app.asar" does not exist. Seems like a wrong configuration.

详细错误

Error: Application entry file "dist\electron\main.js" in the "D:\gui\demo2\build\win-unpacked\resources\app.asar" does not exist. Seems like a wrong configuration.
    at error (D:\gui\demo2\node_modules\electron-builder-lib\src\asar\asarFileChecker.ts:7:12)
    at D:\gui\demo2\node_modules\electron-builder-lib\src\asar\asarFileChecker.ts:33:11
    at Generator.next (<anonymous>)
    at callback (D:\gui\demo2\node_modules\graceful-fs\polyfills.js:299:20)
    at FSReqCallback.oncomplete (fs.js:177:5)
From previous event:
    at checkFileInArchive (D:\gui\demo2\node_modules\electron-builder-lib\out\asar\asarFileChecker.js:46:21)
    at D:\gui\demo2\node_modules\electron-builder-lib\src\platformPackager.ts:322:13
    at Generator.next (<anonymous>)
From previous event:
    at WinPackager.checkFileInPackage (D:\gui\demo2\node_modules\electron-builder-lib\out\platformPackager.js:405:11)
    at D:\gui\demo2\node_modules\electron-builder-lib\src\platformPackager.ts:370:16
    at Generator.next (<anonymous>)
    at callback (D:\gui\demo2\node_modules\graceful-fs\polyfills.js:299:20)
    at FSReqCallback.oncomplete (fs.js:177:5)
From previous event:
    at WinPackager.sanityCheckPackage (D:\gui\demo2\node_modules\electron-builder-lib\out\platformPackager.js:423:11)
    at D:\gui\demo2\node_modules\electron-builder-lib\src\platformPackager.ts:208:16
    at Generator.next (<anonymous>)
    at processImmediate (internal/timers.js:461:21)
From previous event:
    at WinPackager.doPack (D:\gui\demo2\node_modules\electron-builder-lib\out\platformPackager.js:276:11)
    at D:\gui\demo2\node_modules\electron-builder-lib\src\platformPackager.ts:113:16
    at Generator.next (<anonymous>)
From previous event:
    at WinPackager.pack (D:\gui\demo2\node_modules\electron-builder-lib\out\platformPackager.js:196:11)
    at D:\gui\demo2\node_modules\electron-builder-lib\src\packager.ts:364:24
    at Generator.next (<anonymous>)
    at D:\gui\demo2\node_modules\fs-extra-p\node_modules\fs-extra\lib\mkdirs\mkdirs.js:56:16
    at callback (D:\gui\demo2\node_modules\graceful-fs\polyfills.js:299:20)
    at FSReqCallback.oncomplete (fs.js:177:5)
From previous event:
    at Packager.doBuild (D:\gui\demo2\node_modules\electron-builder-lib\out\packager.js:432:11)
    at D:\gui\demo2\node_modules\electron-builder-lib\src\packager.ts:308:52
    at Generator.next (<anonymous>)
    at D:\gui\demo2\node_modules\graceful-fs\graceful-fs.js:144:16
    at D:\gui\demo2\node_modules\graceful-fs\graceful-fs.js:61:14
    at FSReqCallback.oncomplete (fs.js:164:23)
From previous event:
    at Packager._build (D:\gui\demo2\node_modules\electron-builder-lib\out\packager.js:376:11)
    at D:\gui\demo2\node_modules\electron-builder-lib\src\packager.ts:270:23
    at Generator.next (<anonymous>)
From previous event:
    at Packager.build (D:\gui\demo2\node_modules\electron-builder-lib\out\packager.js:332:11)
    at D:\gui\demo2\node_modules\electron-builder\src\builder.ts:310:40
    at Generator.next (<anonymous>)
From previous event:
    at _build (D:\gui\demo2\node_modules\electron-builder\out\builder.js:61:21)
    at build (D:\gui\demo2\node_modules\electron-builder\src\builder.ts:280:10)
    at D:\gui\demo2\node_modules\electron-builder\src\cli\cli.ts:48:33
    at processImmediate (internal/timers.js:461:21)
    at Object.handler (D:\gui\demo2\node_modules\electron-builder\src\cli\cli.ts:48:33)
    at Object.runCommand (D:\gui\demo2\node_modules\electron-builder\node_modules\yargs\lib\command.js:235:44)
    at Object.parseArgs [as _parseArgs] (D:\gui\demo2\node_modules\electron-builder\node_modules\yargs\yargs.js:1050:24)
    at Object.get [as argv] (D:\gui\demo2\node_modules\electron-builder\node_modules\yargs\yargs.js:965:21)
    at Object.<anonymous> (D:\gui\demo2\node_modules\electron-builder\src\cli\cli.ts:42:15)
    at Module._compile (internal/modules/cjs/loader.js:1076:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
    at Module.load (internal/modules/cjs/loader.js:941:32)
    at Function.Module._load (internal/modules/cjs/loader.js:782:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
    at internal/main/run_main_module.js:17:47
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! demo2@0.0.1 build: `node .electron-vue/build.js && electron-builder`
npm ERR! Exit status 1
npm ERR!

从第一句报错:

Error: Application entry file "dist\electron\main.js" in the "D:\gui\demo2\build\win-unpacked\resources\app.asar" does not exist. Seems like a wrong configuration.

出现错误的原因:.electron-vue\build.js文件中,代码中使用了 Multispinner ,但没有在开头引用,并且package.json文件中也没有这个依赖文件。

要解决这个问题首先是先安装

npm install multispinner -D

然后在.electron-vue\build.js文件中引用

const Multispinner = require('multispinner')

再重新进行打包即可。