Uncaught Error: Mismatched anonymous define() module: function definition(name, global)

user2942566

I got this error while loading the requirejs file for the backbone. I tried loading the r.js, the requirejs optimizer, but I'm still stuck with it.

Uncaught Error: Mismatched anonymous define() module: function definition(name, global){

"use strict";

var PubSub = {
        name: 'PubSubJS',
        version: '1.3.1-dev'

Following is my js:

define([
'jquery',
'underscore',
'backbone'
],function(){
subAccountRouter = Backbone.Router.extend({
  routes: {
  // Defining the routes
    'sub-accounts': 'subAccountList',
    '*actions': 'defaultAction'
  },
});

Seems there have been some changes made to requirejs define() call function, somehow cant figure it out. Does anyone have ideas??

EDIT:::

Below is the router.js file.

    define([
       'jquery',
       'underscore',
       'backbone'
      ],function($, _, Backbone){
          SubAccountRouter = Backbone.Router.extend({
              routes: {
               'sub-accounts': 'subAccountList',
               '*actions': 'defaultAction'
              },


           initialize: function () {
              this.appContainer = $("#subaccount");
    //collections and models
              this.subAccountCollection = null;
            this.subAccountModel = null;
          },

      subAccountList: function(){
        var self = this;
        },
     defaultAction: function(){
        this.subAccountList();
      },
      });

    return {
       initialize: function() {
           Backbone.history.start();

          }
        };
     }); //main func

What im i doing wrong here?? I check al my paths and they seem to be correct, i still dont get why this issue is still bugging me..:( I have tried changing the paths for the routes, and also passing arguments to the function($, _, Backbone)(as shown below in 1 of the sol'n). However i still seem to see the error. Does any one have any other ideas???

cs_stackX

UPDATE

After checking the docs - this is actually the first error they discuss:

"If you manually code a script tag in HTML to load a script with an anonymous define() call, this error can occur."

So make sure the only <script> tag (at least for any scripts which call define()) in your index.html is the one to requirejs.

END UPDATE

You need to pass in parameters to your function() like so:

define([
'jquery',
'underscore',
'backbone'
],function(jquery, underscore, backbone){
subAccountRouter = Backbone.Router.extend({
  routes: {
  // Defining the routes
    'sub-accounts': 'subAccountList',
    '*actions': 'defaultAction'
  },
});

I wrote a super-simple post on setting up requirejs recently, if you're still stuck.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Uncaught Error: Mismatched anonymous define() module: function definition(name, global)

From Dev

loading Ace causes Uncaught Error: Mismatched anonymous define() module:

From Dev

Brunch, RequireJS, and ReactJS is giving me "Error: Mismatched anonymous define() module"

From Dev

Mismatched anonymous define() module IE8

From Dev

Mismatched anonymous define() module IE8

From Dev

NG-TABLE - mismatched anonymous define() module

From Dev

"Error: Mismatched anonymous define()" with Karma + RequireJS + Jasmine

From Dev

Backbone.js and Require.js: Mismatched anonymous define() module: function (_, Backbone) {

From Dev

mismatched anonymous define() module typescript with AMD and export module

From Dev

Requirejs with Knockout error: Unable to process binding "component: function (){return f}" - Mismatched anonymous defined() module

From Dev

Requirejs with Knockout error: Unable to process binding "component: function (){return f}" - Mismatched anonymous defined() module

From Dev

Filesaver and requireJS : Mismatched anonymous define

From Dev

Getting "Mismatched anonymous define() module..." when I try running tests

From Dev

Getting "Mismatched anonymous define() module..." when I try running tests

From Dev

Why does this cause "Mismatched anonymous define()" in requireJS?

From Dev

Angular Js Uncaught Error: [$injector:modulerr] anonymous function

From Dev

Mismatched anonymous define() modules when loading external scripts

From Dev

Uncaught Type Error: Undefined is not a function JavaScript Module

From Dev

Uncaught Type Error: Undefined is not a function JavaScript Module

From Dev

Cython Compilation Error: dynamic module does not define module export function

From Dev

Uncaught TypeError undefined is not a function anonymous function

From Dev

Uncaught TypeError: undefined is not a function (anonymous function) in Wordpress

From Dev

Uncaught TypeError: $(...).datepicker is not a function(anonymous function)

From Dev

Uncaught TypeError undefined is not a function anonymous function

From Dev

Uncaught Error: No module: ngRoute

From Dev

uncaught error: No module

From Dev

Uncaught Error: No module: angularTypeahead

From Dev

Uncaught Error: No define call for pnotify

From Dev

Uncaught Error: No define call for reveal

Related Related

  1. 1

    Uncaught Error: Mismatched anonymous define() module: function definition(name, global)

  2. 2

    loading Ace causes Uncaught Error: Mismatched anonymous define() module:

  3. 3

    Brunch, RequireJS, and ReactJS is giving me "Error: Mismatched anonymous define() module"

  4. 4

    Mismatched anonymous define() module IE8

  5. 5

    Mismatched anonymous define() module IE8

  6. 6

    NG-TABLE - mismatched anonymous define() module

  7. 7

    "Error: Mismatched anonymous define()" with Karma + RequireJS + Jasmine

  8. 8

    Backbone.js and Require.js: Mismatched anonymous define() module: function (_, Backbone) {

  9. 9

    mismatched anonymous define() module typescript with AMD and export module

  10. 10

    Requirejs with Knockout error: Unable to process binding "component: function (){return f}" - Mismatched anonymous defined() module

  11. 11

    Requirejs with Knockout error: Unable to process binding "component: function (){return f}" - Mismatched anonymous defined() module

  12. 12

    Filesaver and requireJS : Mismatched anonymous define

  13. 13

    Getting "Mismatched anonymous define() module..." when I try running tests

  14. 14

    Getting "Mismatched anonymous define() module..." when I try running tests

  15. 15

    Why does this cause "Mismatched anonymous define()" in requireJS?

  16. 16

    Angular Js Uncaught Error: [$injector:modulerr] anonymous function

  17. 17

    Mismatched anonymous define() modules when loading external scripts

  18. 18

    Uncaught Type Error: Undefined is not a function JavaScript Module

  19. 19

    Uncaught Type Error: Undefined is not a function JavaScript Module

  20. 20

    Cython Compilation Error: dynamic module does not define module export function

  21. 21

    Uncaught TypeError undefined is not a function anonymous function

  22. 22

    Uncaught TypeError: undefined is not a function (anonymous function) in Wordpress

  23. 23

    Uncaught TypeError: $(...).datepicker is not a function(anonymous function)

  24. 24

    Uncaught TypeError undefined is not a function anonymous function

  25. 25

    Uncaught Error: No module: ngRoute

  26. 26

    uncaught error: No module

  27. 27

    Uncaught Error: No module: angularTypeahead

  28. 28

    Uncaught Error: No define call for pnotify

  29. 29

    Uncaught Error: No define call for reveal

HotTag

Archive