# Common Errors

- Mismatched anonymous define() modules ...§ 1
- Load timeout for modules: ...§ 2
- Error evaluating module ...§ 3
- Module name ... has not been loaded yet for context: ...§ 4
- Invalid require call§ 5
- No matching script interactive for ...§ 6
- Path is not supported: ...§ 7

This page lists errors that are generated by RequireJS. If the following information does not fix the problem, you can ask on the RequireJS list or open an issue. In either case it is best to have an example or detailed explanation of the problem, hopefully with steps to reproduce.

## Mismatched anonymous define() modules ...§ 1

If you manually code a script tag in HTML to load a script with an anonymous define() call, this error can occur.

Also seen if you manually code a script tag in HTML to load a script that has a few named modules, but then try to load an anonymous module that ends up having the same name as one of the named modules in the script loaded by the manually coded script tag.

Finally, if you use the loader plugins or anonymous modules (modules that call define() with no string ID) but do not use the RequireJS optimizer to combine files together, this error can occur. The optimizer knows how to name anonymous modules correctly so that they can be combined with other modules in an optimized file.

To avoid the error:

- Be sure to load all scripts that call define() via the RequireJS API. Do not manually code script tags in HTML to load scripts that have define() calls in them.
- If you manually code an HTML script tag, be sure it only includes named modules, and that an anonymous module that will have the same name as one of the modules in that file is not loaded.
- If the problem is the use of loader plugins or anonymous modules but the RequireJS optimizer is not used for file bundling, use the RequireJS optimizer.

## Load timeout for modules: ...§ 2

Likely causes and fixes:

- There was a script error in one of the listed modules. If there is no script error in the browser's error console, and if you are using Firebug, try loading the page in another browser like Chrome or Safari. Sometimes script errors do not show up in Firebug.
- The path configuration for a module is incorrect. Check the "Net" or "Network" tab in the browser's developer tools to see if there was a 404 for an URL that would map to the module name. Make sure the script file is in the right place. In some cases you may need to use the paths configuration to fix the URL resolution for the script.

## Error evaluating module ...§ 3

An error occured when the define() function was called for the module given in the error message. It is an error with the code logic inside the define function. The error could happen inside a require callback.

In Firefox and WebKit browsers, a line number and file name will be indicated in the error. It can be used to locate the source of the problem. Better isolation of the error can be done by using a debugger to place a breakpoint in the file that contains the error.

## Module name ... has not been loaded yet for context: ...§ 4

This occurs when there is is a require('name') call, but the 'name' module has not been loaded yet.

If you are using the simplified define wrapper, make sure you have require as the first argument to the definition function:

    define(function (require) {
        var namedModule = require('name');
    });

If you are listing dependencies in the dependency array, make sure that require and name are in the dependency array:

    define(['require', 'name'], function (require) {
        var namedModule = require('name');
    });

Or, if part of a require() callback:

    require(['require', 'name'], function (require) {
        var namedModule = require('name');
    });

Be sure that require('name') only occurs inside a define() definition function or a require() callback function, never in the global space by its own.

## Invalid require call§ 4

This occurs when there is is a call like:

    require('dependency', function (dependency) {});

Asynchronously loading dependencies should use an array to list the dependencies:

    require(['dependency'], function (dependency) {});

## No matching script interactive for ...§ 6

This error only shows up in some IE browsers. Most likely caused by loading a script that calls define() but was loaded in a plain script tag or via some other call, like an eval() of a JavaScript string.

To avoid the error, be sure to load all scripts that call define via the RequireJS API.

## Path is not supported: ...§ 7

This error occurs when the optimizer encounters a path to a module or script which is a network path. The optimizer only allows building with local resources. To fix it:

Make sure you reference the network dependency as a module name, not as a full URL, so that it can be mapped to a different during the build:

    //DO NOT DO THIS
    require(['http://some.domain.dom/path/to/dependency.js'],
    function (dependency) {});

    //Rather, do this:
    require.config({
        paths: {
            'dependency': 'http://some.domain.dom/path/to/dependency'
        }
    });

    require(['dependency'], function (dependency) {});

If you want to include this dependency in the built/optimized file, download the JS file and in the build profile for the optimizer, put in a paths config that points to that local file.

If you want to exclude that file from being included, and just need to map "dependency" for the build (otherwise it will not build), then use the special "empty:" paths config:

    //Inside the build profile
    {
        paths: {
            'dependency': 'empty:'
        }
    }