Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8817753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:55:39+00:00 2026-06-14T04:55:39+00:00

When I run the r.js optimizer over my Backbone.js app, I get this error:

  • 0

When I run the r.js optimizer over my Backbone.js app, I get this error:

Uncaught TypeError: undefined is not a function

It appears in the middle of the Backbone.js section of the output.

I removed bits of code until I found out what was causing it, and it seems to be when I call Backbone.history.start();.

I’ve created a simple app to replicate the bug, which I’ve posted below. Basically, it creates a route and ‘console.log’s ‘home’. It works fine when not optimized.

To optimize the app, I use:

node r.js -o app.build.js

from the /js folder.

I have Backbone.js 0.9.2, RequireJS 2.1.1, r.js 2.1.1

Has anyone come across this before? I’m still fairly new to Backbone.js/RequireJS, so hopefully it’s just something stupid I’m doing wrong.

Folder Structure

/js
  /libs
    - backbone.js
    - require.js
    - underscore.js
  - app.build.js
  - r.js
  - site.js
index.html

Code

index.html

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
</head>
<body>

    <script data-main="/js/site.js" src="/js/libs/require.js"></script>

</body>
</html>

site.js

requirejs.config({
    baseUrl     : 'js/',
    paths       : {
        jquery          : '//ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min',
        backbone        : 'libs/backbone',
        underscore      : 'libs/underscore'
    },
    shim        : {
        backbone        : {
            deps            : ['underscore', 'jquery'],
            exports         : 'Backbone'
        },
        underscore      : {
            exports         : '_'
        }
    }
});

require(['jquery', 'backbone'], function($, Backbone) {

    var Router = Backbone.Router.extend({
            routes      : {
                ''          : 'home'
            },
            home        : function(){
                console.log('home');
            }
        }),
        appRouter;

    $(function() {

        appRouter = new Router();
        Backbone.history.start();

    });

});

app.build.js

({
    baseUrl: ".",
    name: 'site',
    paths: {
        jquery: 'empty:',
        underscore: 'libs/underscore',
        backbone: 'libs/backbone'
    },
    out: 'site-built.js',
    shim        : {
        backbone        : {
            deps            : ['underscore', 'jquery'],
            exports         : 'Backbone'
        },
        underscore      : {
            exports         : '_'
        }
    }
})

Thanks!

Update

Here’s the output of site-built.js. Can anyone see anything obviously wrong with it?

http://pastebin.com/Rbm7J83X

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T04:55:41+00:00Added an answer on June 14, 2026 at 4:55 am

    I inlined jQuery and it seems to work OK now. (It’s mentioned at the bottom of the API shim docs on requirejs.org, but not anywhere on the Optimize section.)

    Not sure if this is the correct fix, but hopefully it will help someone else.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to run this query on http://dbpedia.org/sparql but I get an error
I run command: sudo apt-get install phpmyadmin to install phpMyAdmin. Then I enter address:
I run this code here <html> <script type=text/javascript src=lib/jquery-ui-1.8.21.custom.min.js></script> <script src=http://127.0.0.1:5984/_utils/script/jquery.couch.js></script> <!--<script type=text/javascript src=lib/jquery-1.7.2.js></script>-->
I run into this problem. I have a textarea which I only want to
This loop takes forever to run as the amount of items in the loop
I'm not pretty sure if this question is for here, but I want to
Below is my code, after searching so much over the internet; i am not
The Issue Cannot believe I could not find anything on this around the net,
I have an application that is talking to a hardware device over serial. This
I run the following in Apache. Our IT guy recommended Nginx over Apache to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.