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

  • SEARCH
  • Home
  • 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 8752937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:19:59+00:00 2026-06-13T13:19:59+00:00

I am trying to load a module using require.js, and I have the following

  • 0

I am trying to load a module using require.js, and I have the following in my app.js:

require.config({
baseUrl: "js"
});


alert("hello world"); // for debugging

require(['eh2'], function(eh2) {
    alert("nothing here"); // for debugging
});

When I run my application, though, despite the app.js being loaded, the module I’m requiring is never loaded – the “hello world” executes, but the “nothing here” doesn’t!

My script tag in the HTML page looks like this:

<script type="text/javascript" src="js/lib/require.js" data-main="app"></script>

And eh2.js is located in the js folder, and it is wrapped in a define statement:

define(["./screens/Screens"], function(screens) {
    return {
        // code here
    };
});

What am I doing wrong? Is require.js silently failing on loading some submodule under screens.js, perhaps?

Here is the code from the Screens module:

    define([ "screens/TitleScreen", "screens/GameScreen" ], function(titleScreen, gameScreen) {
    return {

        screenFuncs: {
            "TitleScreen" : titleScreen.TitleScreen,
            "GameScreen" : gameScreen.GameScreen,
        },

        buildScreen: function(data) {
            var func = screenFuncs[data.type];
            var screen = new func(data.params);
            return screen;
        },
    };
});

Do the paths in the define call need to be relative to the current location of the js file I’m in, or to the root defined in the app.js, anyway?

  • 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-13T13:20:01+00:00Added an answer on June 13, 2026 at 1:20 pm

    replace this:

    define(["./screens/Screens"], function(screens) {
        ....
    });
    

    either with an absolut path variant:

    define(["screens/Screens"], function(screens) {
        ....
    });
    

    or use:

    define(function(require) {
        var screens = require("./screens/Screens");
        ....
    });
    

    From the docs:

    Relative module names inside define():

    For require(“./relative/name”)
    calls that can happen inside a define() function call, be sure to ask
    for “require” as a dependency, so that the relative name is resolved
    correctly:

    define(["require", "./relative/name"], function(require) {
        var mod = require("./relative/name");
    });
    

    Or better yet, use the shortened syntax that is available for use with translating CommonJS
    modules:

    define(function(require) {
        var mod = require("./relative/name");
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to work out how to load a module using example http://dojotoolkit.org/reference-guide/dojo/registerModulePath.html I
Please, I have the following problem: I'm trying to dynamically load a WCF RIA
I am trying to write a module`to load a Stamen tile map under Require.js,
I'm trying to load Ext.ux.CheckColumn and using the following code: Ext.Loader.setConfig({enabled: true}); Ext.Loader.setPath('Ext.ux', '../ux');
I'm an absolute beginner using Joomla. I'm trying to load a module within another
I am trying to load specific styles/script resources for a specific module within my
I'm trying to create a widget within the module and then load that widget
I'm trying to get require.js to load modules on the server-side with Java 6
I have a problem with out of memory when I'm trying load a few
I am trying to use require.js for loading js scripts simply using firebug console

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.