Electron打包错误

最近想学习一下Electron的开发流程,进入https://www.electronjs.org/docs/tutorial/quick-start跟着教程依次操作,前面几部都很顺利,直到打包阶段,错误他还是没放过我

按照文档上的说明,在工程目录执行npm run make,开始执行打包步骤,起初一切看起来都很正常,但是在执行了几十秒后,错误catch了我

Debugger attached.
√ Checking your system
Debugger attached.
√ Resolving Forge Config
We need to package your application before we can make it
√ Preparing to Package Application for arch: x64
√ Preparing native dependencies
√ Packaging Application
Making for the following targets: squirrel
× Making for target: squirrel - On platform: win32 - For arch: x64

An unhandled error has occurred inside Forge:
An error occured while making for target: squirrel
Failed with exit code: 1
Output:
���ڳ��Դӡ�test_electron.nuspec�����ɳ������
Authors is required.
Description is required.

Error: Failed with exit code: 1
Output:
���ڳ��Դӡ�test_electron.nuspec�����ɳ������
Authors is required.
Description is required.

    at ChildProcess.<anonymous> (E:\work\node\test-electron\node_modules\electron-winstaller\src\spawn-promise.ts:52:16)
    at ChildProcess.emit (events.js:315:20)
    at ChildProcess.EventEmitter.emit (domain.js:486:12)
    at maybeClose (internal/child_process.js:1048:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
    at Process.callbackTrampoline (internal/async_hooks.js:129:14)
Waiting for the debugger to disconnect...
Waiting for the debugger to disconnect...
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! test-electron@1.0.0 make: `electron-forge make`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the test-electron@1.0.0 make script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\MortalGod\AppData\Roaming\npm-cache\_logs\2020-12-12T15_35_59_799Z-debug.log
Waiting for the debugger to disconnect...

乱码是原生的,我的终端里打印出来的就是乱码,不过乱码我们不关心,我们关心的是错误

第一步,当然是问度娘,先搜node_modules\electron-winstaller\src\spawn-promise.ts,没有任何有用的东西,关键词不对,换一个!

搜Authors is required.Description is required. 这次还不错,发现了一个基本一样的错误内容,点进去看,是用NuGet打包报的错,不是Electron的,关掉,再找找,除此之外竟然没有匹配的了,再点进去看看第一个吧,哦?竟然重新执行一遍就行了?不管了,先试试,万一这是个跨平台错误呢。

然鹅,错误很坚持自己的存在,原样报错。

百度真的是越来越不行了,换bing国际版,搜,让bing教教百度怎么做搜索,然鹅,又是然鹅,还是没有有价值的帖子,好吧,bing没能抓住给自己长脸的机会。

Authors和Description会不会是node包呢,搜,authors倒是有个包,description啥也没有,但是node require包也没见过首字母大写的啊,这到底是个什么鬼?

难道就没人碰到过这个错误么,Electron发展了这么长时间,我一用就发现了个深藏不漏的问题,还是大家解决了问题都不说,好吧,祭出调试大法,话说现在VS调试功能真是比之前好用多了,原来还要配置launch.json,现在可以直接在package.json里点Debug就能调试了,费了九牛二虎之力,一步一步跟踪,加了无数断点,跟到了node_modules\electron-winstaller\lib\index.js的以下位置

                case 8:
                    Object.assign(metadata, options);
                    if (!metadata.authors) {
                        if (typeof (metadata.author) === 'string') {
                            metadata.authors = metadata.author;
                        }
                        else {
                            // eslint-disable-next-line @typescript-eslint/no-object-literal-type-assertion
                            metadata.authors = (metadata.author || {}).name || '';
                        }
                    }
                    metadata.owners = metadata.owners || metadata.authors;
                    metadata.version = convertVersion(metadata.version);
                    metadata.copyright = metadata.copyright ||
                        "Copyright \u00A9 " + new Date().getFullYear() + " " + (metadata.authors || metadata.owners);
                    return [4 /*yield*/, fs.readFile(path.join(__dirname, '..', 'template.nuspectemplate'), 'utf8')];

这个meta是个什么玩意,看了以下内容,似乎是工程的配置信息,WTF,难道Authors和Description是工程的配置项?到package.json里一看,果然有Author和Description的配置项,目前都是空字符串,随便填点儿东西,在执行一下试试,我去,竟然成功了。

话说这个错误提示真的是无语,错误堆栈都是一堆没用的东西,为啥不能提示我去确认一下package.json的配置,而且为啥是执行半天了才想起来去检查配置信息,配置检查不是应该放在最开始么,大坝快建成了才发现河里没水么?

不过我最想不通的还是难道大家都没碰到过这个错误,这可是按照官方文档的步骤操作的啊,难道大家都是上来就把所有设置全填上的么,npm init的时候没有自动填啊,还是版版本升级了,文档还没改,我成了第一个吃螃蟹的人?

希望后面再有人碰到这个错误,能看到这篇记录,不要再浪费那么多时间了。

  • 33
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 18
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 18
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值