0

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>
1
  • If you're running this locally on your machine, then use relative paths instead of absolute path for require.js. Change your src to /js/requirejs.js Commented Mar 7, 2015 at 17:18

2 Answers 2

1
<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 :)

Sign up to request clarification or add additional context in comments.

Comments

0

[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

2 Comments

What url? thats just a local site on my machine.
mbms.com/js/requirejs.js is not a URL? If you're overriding the public DNS for mbms.com, explain that in the question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.