简体   繁体   中英

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. this error is pointing at app/dist/packaged-app-win32-x64... and the error is displayed below:

错误窗口

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:

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 .

Here are the available options :

  • ia32
  • x64
  • armv7l
  • arm64
  • 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]."

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.

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). 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. I'm sharing the problem I had faced, while closing the window. and solved it myself. 我的问题截图

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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