[Electron] Integrating select2 within Electron Framework

Hi,
I have been using jQuery, bootstrap, select2 within Electron Framework Project. Recently, I updated NodeJs and npm, and I started experiencing problem with loading select2 package. I am getting this error: “Uncaught TypeError: $(…).select2 is not a function”. whenever select2 function is called. I have searched, read and tried several solutions. So far I have tried, checking the order of (jQuery, Bootstrap and select2) being loaded that specific order, different versions of jQuery are not being attached to the html page, downloading all packages and using in the file through local path, manually trying to add select2 to $.fn object. But nothing works for me. I also tried removing node_modules, clearing npm cache and installing everything. But that also didn’t help.

To isolate the problem, I downloaded the electron-quick-start project and replaced the index.html file with this gist file link to the index.html .

When I opened index.html file in the chrome browser, I see no error and select2 is loaded and I also see it in the Object $.fn. But when I started the electron project, it is giving me the same error as I was getting previously with my project. I am using Node v8.9.1, npm 5.5.1 (installed through homebrew).

I would appreciate any insights, link to any other posts which I might have missed and any suggestions to resolve this issue.

I tried different versions (4.0.3, 4.0.4,4.0.5, 4.0.6-rc.0) of select2 within Electron. Only select2 version 4.0.3 worked within Electron.
Regarding the error in my project due to select2: npm installed a latest version of select2 (as specified with ‘^’ suffixed with version number) got installed causing that error. Now, I have made changes to the package.json of my project to install only version 4.0.3 of select2 and my project is running without any errors.

Is it possible that this is related to this issue, which also came up after the v4.0.4 release?

Yes, the issue seems to be relevant to what I am experiencing within my project. Thank you for pointing to the discussion around it. As I understand from the discussion, the issue is still open.

Yep! I’m not really sure how to resolve it at the moment. The folks at umdjs seem to suggest that this new pattern is the “correct” way of implementing umd support in a jQuery plugin. But, obviously this is a breaking change for a lot of people :slightly_frowning_face:

What is the status about this?

Thanks