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 9152345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:01:11+00:00 2026-06-17T12:01:11+00:00

I have my config (main.js) defined as: require.config({ urlArgs: bust= + (new Date()).getTime(), paths:

  • 0

I have my config (main.js) defined as:

require.config({
    urlArgs: "bust=" + (new Date()).getTime(),
    paths: {
        jquery: 'jquery-1.8.3.min',
        knockout: 'knockout-2.2.0',
        komapping: 'knockout.mapping-latest',
        token: 'jquery.tokeninput'
    },
    shim: {
        'token': ['jquery']
    }
});

EDIT
main.js is a shared configuration. I have several pages that all use the same setup and I don’t want to need to modify version-specific filenames all over the place in my project.
/EDIT

and included in the page as:

<script src="/AnswersDev/Scripts/require.js" data-main="/AnswersDev/Scripts/main"></script>

add-report.js is included as:

<script type="text/javascript">
    require(['Views/add-report']);
</script>

EDIT
That appears likely to be the cause. The inline script is sometimes running before main, and therefore the aliases it is expecting to find are not defined, so it just goes looking for .js.
/EDIT

jquery.tokeninput is AFAIK, the only non-AMD module I’m using. A working request results in the following sequence of request (Fiddler capture):

  1. require.js
  2. main.js
  3. Views/add-report.js
  4. Views/add-report-wizard-model.js
  5. knockout-2.2.0
  6. jquery-1.8.3.min.js
  7. Views/add-report-wizard-model-parameter.js
  8. Views/add-report-wizard-model-step.js
  9. knockout.mapping-latest.js

A non-working request has a sequence like e.g.:

  1. require.js
  2. Views/add-report.js
  3. main.js
  4. Views/add-report-wizard-model.js
  5. knockout.js
  6. jquery.js
  7. Views/add-report-wizard-model-step.js
  8. Views/add-report-wizard-model-parameter.js
  9. knockout.mapping-latest.js

add-report.js:

define(['jquery', 'knockout', 'Views/add-report-wizard-model'], function ($, ko, ViewModel) {
... snip ...
});

Note that in the non-working sequence, add-report.js is requested before require.js (I expected that non-deterministic load order applied after require.js is loaded) and both knockout and jquery (both having AMD support built in) are being requested with the wrong file names. I have observed other sequences where require is requested before add-report and the knockout and jquery file names are still wrong. The only thing I am doing between requests is refreshing the browser (I’ll also note that once it works, it tends to keep working, and once it breaks, it tends to stay broken). I’ve tried removing urlArgs from the config and still observe the same issue. On this particular page, jquery.tokeninput is not used. Removing it from the config file does not appear to have any effect either.

At this point, RequireJS is completely unreliable for me and I certainly cannot release my code to production in the current state. Given the number of people who seem to be using RequireJS quite successfully, I can only assume that the problem is in my code somewhere, but I’m at a loss as to where that might be.

Anyone have any suggestions where I might have gone wrong? Thanks.

EDIT: As requested, excerpt from knockout.mapping-latest.debug.js:

// Module systems magic dance.

if (typeof require === "function" && typeof exports === "object" && typeof module === "object") {
    // CommonJS or Node: hard-coded dependency on "knockout"
    factory(require("knockout"), exports);
} else if (typeof define === "function" && define["amd"]) {
    // AMD anonymous module with hard-coded dependency on "knockout"
    define(["knockout", "exports"], factory);
} else {
    // <script> tag: use the global `ko` object, attaching a `mapping` property
    factory(ko, ko.mapping = {});
}
  • 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-17T12:01:13+00:00Added an answer on June 17, 2026 at 12:01 pm

    When you request your files like this:

    <script src="/AnswersDev/Scripts/require.js" data-main="/AnswersDev/Scripts/main"></script>
    <script type="text/javascript">
        require(['Views/add-report']);
    </script>
    

    Chances are that the inline require is called before the main.js script (where is your config if I understand correctly).

    So you all need to load from the main.js files. You can use the config deps option to load some files. Or you could also all include them inline, but that defeat the purpose.

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

Sidebar

Related Questions

I have defined a RequireJs configuration which defines paths and shims: require.config({ // define
I have this situation: js/main.js require.config({ 'baseUrl' : 'js', 'waitSeconds' : 45, 'paths': {
I have an ASP.NET application with a <codeSubDirectories> section in web.config. My main project
In my web.config I have configured a SiteMapProvider with securityTrimmingEnabled=true and on my main
I have a Yii project with a main.php config file and dev.php config file
I have a setup for a test app which includes require.js, jQuery, jQueryMobile (jqm),
I am trying to build a small application using knockout, require, underscore. I have
I have a mule-config file where i have defined a http inbound to accept
I have a php file named config.php in which I defined the application settings
Say I have a class I defined called 'MyClass'. My 'main' method takes as

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.