imperium2335
imperium2335

Reputation: 24132

RequireJS object not defined

I keep getting:

Uncaught TypeError: object is not a function

The first time:

<script>
    require(['core/controller']);
</script>

The secondoccurrence is:

require.config({
    paths: {
        "jquery": [
            "jquery"
        ],
        'bootstrap': [
            'bootstrap'
        ],
        'kendo': [
            'kendo'
        ],
        handlebars: 'handlebars'
    },
    shim: {
        "bootstrap": {
            deps :["jquery"]
        },
        "kendo": {
            deps: ["jquery"]
        }
    }
})

define('config', function (require) {
    'use strict';

    var module = require('module');

    return module.config ? module.config() : {};
});

define('events', ['core/mini-events'], function(EventEmitter){

    var events = new EventEmitter();

    return events;

});

In my header I have:

<script data-main="/js/main.js" src="http://mbms.com/js/requirejs.js"></script>

Upvotes: 0

Views: 529

Answers (2)

Arkantos
Arkantos

Reputation: 6608

<script data-main="/js/main.js" src="http://mbms.com/js/requirejs.js"></script>

The absolute URL that you mentioned in your script's src doesn't exist. As the host and the file do not exist, requirejs.js is not downloaded and any attempt to use require API will give you the error that you're getting now. As you're running this locally, I suggest you change your src like below

<script data-main="/js/main.js" src="/js/requirejs.js"></script>

As long as there's a js folder with requirejs.js file under your project root folder, then this change should work :)

Upvotes: 1

BaseZen
BaseZen

Reputation: 8718

[EDIT for clarity] I tried the URL referenced in the script tag just now and it's not present. Check your debugger's Network console and you'll see the 404. Perhaps you meant:

http://requirejs.org/docs/release/2.1.16/minified/require.js

Upvotes: 0

Related Questions