当前位置:   article > 正文

Electron打包错误_description is required.

description is required.

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

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

  1. Debugger attached.
  2. √ Checking your system
  3. Debugger attached.
  4. √ Resolving Forge Config
  5. We need to package your application before we can make it
  6. √ Preparing to Package Application for arch: x64
  7. √ Preparing native dependencies
  8. √ Packaging Application
  9. Making for the following targets: squirrel
  10. × Making for target: squirrel - On platform: win32 - For arch: x64
  11. An unhandled error has occurred inside Forge:
  12. An error occured while making for target: squirrel
  13. Failed with exit code: 1
  14. Output:
  15. ���ڳ��Դӡ�test_electron.nuspec�����ɳ������
  16. Authors is required.
  17. Description is required.
  18. Error: Failed with exit code: 1
  19. Output:
  20. ���ڳ��Դӡ�test_electron.nuspec�����ɳ������
  21. Authors is required.
  22. Description is required.
  23. at ChildProcess.<anonymous> (E:\work\node\test-electron\node_modules\electron-winstaller\src\spawn-promise.ts:52:16)
  24. at ChildProcess.emit (events.js:315:20)
  25. at ChildProcess.EventEmitter.emit (domain.js:486:12)
  26. at maybeClose (internal/child_process.js:1048:16)
  27. at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
  28. at Process.callbackTrampoline (internal/async_hooks.js:129:14)
  29. Waiting for the debugger to disconnect...
  30. Waiting for the debugger to disconnect...
  31. npm ERR! code ELIFECYCLE
  32. npm ERR! errno 1
  33. npm ERR! test-electron@1.0.0 make: `electron-forge make`
  34. npm ERR! Exit status 1
  35. npm ERR!
  36. npm ERR! Failed at the test-electron@1.0.0 make script.
  37. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
  38. npm ERR! A complete log of this run can be found in:
  39. npm ERR! C:\Users\MortalGod\AppData\Roaming\npm-cache\_logs\2020-12-12T15_35_59_799Z-debug.log
  40. 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的以下位置

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

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

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

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

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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/代码探险家/article/detail/965078
推荐阅读
相关标签
  

闽ICP备14008679号