javascriptjqueryrequirejs

Mismatched anonymous define() module


I'm getting this error when I browse my webapp for the first time (usually in a browser with disabled cache).

Error: Mismatched anonymous define() module: function (require) {

HTML:

<html>
   .
   .
   .
   <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
   <script> var require = { urlArgs: "v=0.4.1.32" }; </script>
   <script data-main="assets/js/main" src="assets/js/libs/require.js"></script>
   <script src="assets/js/ace/ace.js?v=0.4.1.32"></script>
   </body>
</html>

JS:

$(function () {
    define(function (require) {
        // do something
    });
});

Anyone know exactly what this error means and why it's happening?

source file, a short discussion about it in the github issues page


Solution

  • Like AlienWebguy said, per the docs, require.js can blow up if

    I had this problem while including bundles built with browserify alongside require.js modules. The solution was to either:

    A. load the non-require.js standalone bundles in script tags before require.js is loaded, or

    B. load them using require.js (instead of a script tag)