Uncaught TypeError: $(...).select2 is not a function
See original GitHub issueUsed select2 in app/design/frontend/Vendor/theme/Magento_ConfigurableProduct/web/js/configurable-mixin.js
In console get error Uncaught TypeError: $(...).select2 is not a function
.
Added select2 to define(). Get another error
Uncaught Error: Mismatched anonymous define() module: function(e){var t=function(){if(e&&e.fn&&e.fn.select2&&e.fn.select2.amd)var t=e.fn.select2.amd;var n,i,r,o,s,a,l,u,c,d,h,f,p,m,g,v;function y(e,t){return p.call(e,t)}function b(e,t){var n,i,r,o,s,a,l,u,c,d,f,p=t&&t.split("/"),m=h.map,v=m&&m["*"]||{};if(e){for(s=(e=e.split("/")).length-1,h.nodeIdCompat&&g.test(e[s])&&(e[s]=e[s].replace(g,"")),"."===e[0].charAt(0)&&p&&(e=p.slice(0,p.length-1).concat(e)),c=0;c<e.length;c++)if("."===(f=e[c]))e.splice(c,1),c-=1;else if(".."===f){if(0===c||1===c&&".."===e[2]||".."===e[c-1])continue;0<c&&(e.splice(c-1,2),c-=2)}e=e.join("/")}if((p||v)&&m){for(c=(n=e.split("/")).length;0<c;c-=1){if(i=n.slice(0,c).join("/"),p)for(d=p.length;0<d;d-=1)if(r=(r=m[p.slice(0,d).join("/")])&&r[i]){o=r,a=c;break}if(o)break;!l&&v&&v[i]&&(l=v[i],u=c)}!o&&l&&(o=l,a=u),o&&(n.splice(0,a,o),e=n.join("/"))}return e}function _(e,t){return function(){var n=m.call(arguments,0);return"string"!=typeof n[0]&&1===n.length&&n.push(null),a.apply(o,…
makeError https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:16
intakeDefines https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:77
localRequire https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:97
load https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/mage/requirejs/mixins.min.js:8
callPlugin https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:71
bind https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:11
on https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:40
require.min.js:16:53
makeError https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:16
intakeDefines https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:77
localRequire https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:97
load https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/mage/requirejs/mixins.min.js:8
callPlugin https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:71
bind https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:11
on https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:40
callPlugin https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:61
fetch https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:55
check https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:56
enable https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:73
enable https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:101
enable https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:73
bind https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:11
each https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:3
enable https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:71
enable https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:101
enable https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:73
bind https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:11
each https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:3
enable https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:71
init https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:54
callGetModule https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:74
intakeDefines https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:77
localRequire https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:97
load https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/mage/requirejs/mixins.min.js:8
callPlugin https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:71
bind https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:11
on https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:40
callPlugin https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:61
fetch https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:55
check https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:56
enable https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:73
enable https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:101
enable https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:73
bind https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:11
each https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:3
enable https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:71
enable https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:101
enable https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:73
bind https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:11
each https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:3
enable https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:71
init https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:54
callGetModule https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:74
intakeDefines https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:77
localRequire https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:97
load https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/mage/requirejs/mixins.min.js:8
callPlugin https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:71
bind https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:11
on https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:40
callPlugin https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:61
fetch https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:55
check https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:56
enable https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:73
enable https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:101
enable https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:73
bind https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:11
each https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:3
enable https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:71
init https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:54
callGetModule https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:74
intakeDefines https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:77
localRequire https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:97
load https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/mage/requirejs/mixins.min.js:8
callPlugin https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:71
bind https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:11
on https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:40
callPlugin https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:61
fetch https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:55
check https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:56
enable https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:73
enable https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:101
enable https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:73
bind https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:11
each https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:3
enable https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:71
enable https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:101
enable https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:73
bind https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:11
each https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:3
enable https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:71
enable https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:101
enable https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:73
bind https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:11
each https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:3
enable https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:71
init https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:54
callGetModule https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:74
intakeDefines https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:77
localRequire https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:97
load https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/mage/requirejs/mixins.min.js:8
callPlugin https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:71
bind https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:11
on https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:40
callPlugin https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:61
fetch https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:55
check https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:56
enable https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:73
enable https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:101
enable https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:73
bind https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:11
each https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:3
enable https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:71
init https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:54
callGetModule https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:74
completeLoad https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:103
onScriptLoad https://mcstaging.blundstone.com/static/version1595448073/frontend/Blundstone/default/en_US/requirejs/require.min.js:112
Bonus question.
In ReadMe sayed that command magepack bundle
have an options. But this options not described. Can you add some examples to ReadMe?
Issue Analytics
- State:
- Created 3 years ago
- Comments:7
Top Results From Across the Web
Select2() is not a function - Stack Overflow
This error raises if your js files where you have bounded the select2 with select box is loading before select2 js files ...
Read more >TypeError: $(...).select2 is not a function in jQuery | bobbyhadz
To solve the "$(...).select2 is not a function" jQuery error, make sure to load the jQuery library before loading the select2 library. The...
Read more >[BUG] `Uncaught TypeError: $(...).select2 is not a function` with ...
I get the error Uncaught TypeError: $(...).select2 is not a function. I'm not sure if it's related to using webpack or because I'm...
Read more >Select2 is not a function - Integrations
I'm trying to use select2 through webpack. Here's what I get : TypeError: $(...).select2 is not a function. My package.json :.
Read more >jQuery.Deferred exception: $(...).select2 is not a function ...
Yii2 returns select 2 errror on console and no jquery functionalities working due to this error The ... select2 is not a function...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@krzksz FYI It doesn’t work because select2 lib includes
define(
multiple times for example:define(['jquery'], factory);
S2.requirejs = requirejs;S2.require = require;S2.define = define;
S2.define("almond", function(){});
here’s the condition from
magepack/lib/bundle.js
It will not work because it will catch
define("almond"
Not sure how to fix it but maybe you can check if there is no
.
beforedefine
in this expression or just search for only first occurance ofdefine
@orthener I discovered when bundling with Magepack the select2 module doesn’t get a unique name so once part of the bundle file you get the anonymous mismatched error.
As a quick fix you can manually add a name to the select2.js which will then allow it to work correctly in the bundle, see below.
(function (factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. define('**your_unque_name**', ['jquery'], factory); } else if (typeof module === 'object' && module.exports) {