richardmyu / blog

个人(issues)博客
https://github.com/richardmyu/blog/issues
MIT License
0 stars 0 forks source link

eletron 相关问题 #35

Open richardmyu opened 2 years ago

richardmyu commented 2 years ago

1.electron-forge make

➜ npm run make

> desktop-dictionary@1.0.0 make
> electron-forge make

✔ Checking your system
✔ 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

An unhandled rejection has occurred inside Forge:
Error: Could not find any make targets configured for the "win32" platform.

Electron Forge was terminated. Location:
{}

electron-forge make results in Error: Could not find any make targets configured for the "win32" platform

卸载后重装,没有这个问题,但出现了新问题:

➜ npm run make

> desktop-dictionary@1.0.0 make
> electron-forge make

✔ Checking your system
✔ 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

Error: Failed with exit code: 1
Output:
正在尝试从“desktop_dictionary.nuspec”生成程序包。
Authors is required.
Description is required.

    at ChildProcess.<anonymous> (C:\mywork\hubproject\desktop-dictionary\node_modules\electron-winstaller\src\spawn-promise.ts:52:16)
    at ChildProcess.emit (node:events:390:28)
    at ChildProcess.emit (node:domain:475:12)
    at maybeClose (node:internal/child_process:1064:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)

在 package.json 中补充以上信息:

An unhandled error has occurred inside Forge:
An error occured while making for target: squirrel
Failed with exit code: 4294967295
Output:
System.AggregateException: 发生一个或多个错误。 ---> System.ComponentModel.Win32Exception: 系统找不到指定的文件。
   在 System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
   在 System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
   在 Squirrel.Utility.<InvokeProcessAsync>d__11.MoveNext()
--- 引发异常的上一位置中堆栈跟踪的末尾 ---
   在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   在 Squirrel.Utility.<CreateZipFromDirectory>d__23.MoveNext()
   --- 内部异常堆栈跟踪的结尾 ---
   在 System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   在 System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   在 Squirrel.ReleasePackage.CreateReleasePackage(String outputFile, String packagesRootDir, Func`2 releaseNotesProcessor, Action`1 contentsPostProcessHook)
   在 Squirrel.Update.Program.Releasify(String package, String targetDir, String packagesDir, String bootstrapperExe, String backgroundGif, String signingOpts, String baseUrl, String setupIcon, Boolean generateMsi, Boolean packageAs64Bit, String frameworkVersion, Boolean generateDeltas)
   在 Squirrel.Update.Program.executeCommandLine(String[] args)
   在 Squirrel.Update.Program.main(String[] args)
   在 Squirrel.Update.Program.Main(String[] args)
---> (内部异常 #0) System.ComponentModel.Win32Exception (0x80004005): 系统找不到指定的文件。
   在 System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
   在 System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
   在 Squirrel.Utility.<InvokeProcessAsync>d__11.MoveNext()
--- 引发异常的上一位置中堆栈跟踪的末尾 ---
   在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   在 Squirrel.Utility.<CreateZipFromDirectory>d__23.MoveNext()<---

PathTooLongException when making squirrel #1600 Signing with Squirrel Maker and token-based EV certificate fails #2545


回头再看,感觉是配置问题。

都删除后,重新安装,根据官网,添加配置。

安装 electron-forge 后的默认配置:

 "config": {
    "forge": {
      "packagerConfig": {},
      "makers": [
        {
          "name": "@electron-forge/maker-squirrel",
          "config": {
            "name": "desktop_dictionary"
          }
        },
        {
          "name": "@electron-forge/maker-zip",
          "platforms": [
            "darwin",
            "linux"
          ]
        },
        {
          "name": "@electron-forge/maker-deb",
          "config": {
            "options": {
              "maintainer": "desktop-dictionary"
            }
          }
        },
        {
          "name": "@electron-forge/maker-rpm",
          "config": {
            "options": {
              "maintainer": "desktop-dictionary"
            }
          }
        }
      ]
    }
  }

修改后的配置:

  "config": {
    "forge": {
      "packagerConfig": {},
      "makers": [
        {
          "name": "@electron-forge/maker-squirrel",
          "config": {
            "name": "desktop_dictionary"
          }
        },
        {
          "name": "@electron-forge/maker-zip",
          "platforms": [
            "darwin",
            "linux"
          ],
          "config": {}
        },
        {
          "name": "@electron-forge/maker-deb",
          "config": {
            "options": {
              "maintainer": "yum",
              "homepage": "https://xx/"
            }
          }
        },
        {
          "name": "@electron-forge/maker-rpm",
          "config": {
            "options": {
              "maintainer": "yum",
              "homepage": "https://xx/"
            }
          }
        }
      ]
    }
  }

然后打包没有异常,不能说成功,因为没有输出预期的“打包”文件。

darkfiredarkhalo commented 2 years ago

大佬, electron-forge怎么和electron-updater结合使用? 因为 electron-forgewindows平台的打包方式是Squirrel, 而electron-updaterwindows平台只支持nsis....
如果使用electron内置的autoUpdater, 则会报和你上边所示一样的错误