最近想學習一下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的時候沒有自動填啊,還是版版本升級了,檔案還沒改,我成了第一個吃螃蟹的人?
希望后面再有人碰到這個錯誤,能看到這篇記錄,不要再浪費那么多時間了,
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/234914.html
標籤:其他
上一篇:node.js操作
