简体   繁体   English

主进程中发生 JavaScript 错误:TypeError: Insufficient number of arguments

[英]JavaScript error occurred in the main Process: TypeError: Insufficient number of arguments

In the process of attempting to package an electron project using electron-packager npm module, an error continues to show up upon running the .exe of the packaged product.在尝试使用electron-packager npm模块打包一个electron项目的过程中,运行打包后的产品的.exe时继续报错。 this error is pointing at app/dist/packaged-app-win32-x64... and the error is displayed below:此错误指向 app/dist/packaged-app-win32-x64...,错误显示如下:

错误窗口

I'm not really sure what this insufficient number of arguments is referring to and the error isn't very helpful for me to find it out.我不太确定这个数量不足的参数指的是什么,而且这个错误对我找出它不是很有帮助。

as a side note, the application actually does open up and function properly after closing the error window, but no longer shows the tray icon as it should.作为旁注,在关闭错误窗口后,应用程序实际上会打开并正常运行,但不再显示应有的托盘图标。

the cli command for electron packager that was used to package this app:用于打包此应用程序的电子打包程序的 cli 命令:

electron-packager . App-Name --overwrite --asar --platform=win32 --icon=assets/icons/Icon.ico --prune=true --out=./dist

I haven't used the electron-packager module yet, but from their docs it appears you may have to set an argument for architecture, ie, --arch .我还没有使用过electron-packager模块,但是从他们的文档看来,您可能需要为架构设置一个参数,即--arch

Here are the available options :以下是可用选项

  • ia32 ia32
  • x64 x64
  • armv7l armv7l
  • arm64手臂64
  • mips64el mips64el
  • all全部

It appears if you set it to all ( --arch all ) it will "[bundle] for all valid combinations of [the] target [platform you set]."如果您将其设置为所有( --arch all ),它将显示为“[捆绑] 用于 [您设置的] 目标 [平台] 的所有有效组合。”

Like I said, I haven't used the package so this might not work.就像我说的,我没有使用过这个包,所以这可能不起作用。 But I thought it'd be worth a try!但我觉得值得一试!

Turns out my declaration of a tray had no argument to pull an icon from and that's where the error was coming from.原来我对托盘的声明没有理由从中拉出一个图标,这就是错误的来源。 i gave the tray instantiation an icon path to use, re-packaged, and ran the .exe and it works perfectly.我为托盘实例提供了一个图标路径以供使用、重新打包并运行 .exe,它运行良好。

The column that the error reminded is slightly inaccurate.so i suggest that you search the functions nearby that column in your code to see how many arguments they need.错误提示的列有点不准确。所以我建议您在代码中搜索该列附近的函数,以查看它们需要多少个参数。 I have met this question too.It indicates that I lack the necessary parameters.For example, i use Session.cookies.remove(url, str, callback).我也遇到过这个问题,说明我缺少必要的参数。例如,我使用Session.cookies.remove(url, str, callback)。 However i not use callback argument.但是我不使用回调参数。 so when i package an electron project, it show error.所以当我打包一个电子项目时,它显示错误。 After i add callback, the error dispear.添加回调后,错误消失。

I suggest, figure out errors in your javascript codes.我建议,找出您的 javascript 代码中的错误。 I'm sharing the problem I had faced, while closing the window.我正在分享我在关闭窗口时遇到的问题。 and solved it myself.并自己解决了。 我的问题截图

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM