/
errors.html
155 lines (103 loc) · 7.58 KB
/
errors.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<div id="directory" class="section">
<h1>Common Errors</h1>
<ul class="index mono">
<li class="hbox"><a href="#mismatch">Mismatched anonymous define() modules ...</a><span class="spacer boxFlex"></span><span class="sect">§ 1</span></li>
<li class="hbox"><a href="#timeout">Load timeout for modules: ...</a><span class="spacer boxFlex"></span><span class="sect">§ 2</span></li>
<li class="hbox"><a href="#defineerror">Error evaluating module ...</a><span class="spacer boxFlex"></span><span class="sect">§ 3</span></li>
<li class="hbox"><a href="#notloaded">Module name ... has not been loaded yet for context: ...</a><span class="spacer boxFlex"></span><span class="sect">§ 4</span></li>
<li class="hbox"><a href="#requireargs">Invalid require call</a><span class="spacer boxFlex"></span><span class="sect">§ 5</span></li>
<li class="hbox"><a href="#interactive">No matching script interactive for ...</a><span class="spacer boxFlex"></span><span class="sect">§ 6</span></li>
<li class="hbox"><a href="#pathnotsupported">Path is not supported: ...</a><span class="spacer boxFlex"></span><span class="sect">§ 7</span></li>
</ul>
<p>This page lists errors that are generated by RequireJS. If the following information does not fix the problem, you can ask on the <a href="https://groups.google.com/group/requirejs">RequireJS list</a> or <a href="https://github.com/jrburke/requirejs/issues">open an issue</a>. In either case it is best to have an example or detailed explanation of the problem, hopefully with steps to reproduce.</p>
</div>
<div class="section">
<h2><a name="mismatch">Mismatched anonymous define() modules ...</a><span class="sectionMark">§ 1</span></h2>
<p>If you manually code a script tag in HTML to load a script with an anonymous define() call, this error can occur.</p>
<p>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.</p>
<p>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.</p>
<p>To avoid the error:</p>
<ul>
<li>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.</li>
<li>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.</li>
<li>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.</li>
</ul>
</div>
<div class="section">
<h2><a name="timeout">Load timeout for modules: ...</a><span class="sectionMark">§ 2</span></h2>
<p>Likely causes and fixes:</p>
<ul>
<li>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.</li>
<li>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 <a href="api.html#config">paths configuration</a> to fix the URL resolution for the script.</li>
</ul>
</div>
<div class="section">
<h2><a name="defineerror">Error evaluating module ...</a><span class="sectionMark">§ 3</span></h2>
<p>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.</p>
<p>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.</p>
</div>
<div class="section">
<h2><a name="notloaded">Module name ... has not been loaded yet for context: ...</a><span class="sectionMark">§ 4</span></h2>
<p>This occurs when there is is a require('name') call, but the 'name' module has not been loaded yet.</p>
<p>If you are using the simplified define wrapper, make sure you have <strong>require</strong> as the first argument to the definition function:</p>
<pre><code>define(function (require) {
var namedModule = require('name');
});
</code></pre>
<p>If you are listing dependencies in the dependency array, make sure that <strong>require</strong> and <strong>name</strong> are in the dependency array:</p>
<pre><code>define(['require', 'name'], function (require) {
var namedModule = require('name');
});
</code></pre>
<p>Or, if part of a require() callback:</p>
<pre><code>require(['require', 'name'], function (require) {
var namedModule = require('name');
});
</code></pre>
<p>Be sure that <strong>require('name')</strong> only occurs inside a define() definition function or a require() callback function, never in the global space by its own.</p>
</div>
<div class="section">
<h2><a name="requireargs">Invalid require call</a><span class="sectionMark">§ 4</span></h2>
<p>This occurs when there is is a call like:</p>
<pre><code>require('dependency', function (dependency) {});
</code></pre>
<p>Asynchronously loading dependencies should use an array to list the dependencies:</p>
<pre><code>require(['dependency'], function (dependency) {});
</code></pre>
</div>
<div class="section">
<h2><a name="interactive">No matching script interactive for ...</a><span class="sectionMark">§ 6</span></h2>
<p>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.</p>
<p>To avoid the error, be sure to load all scripts that call define via the RequireJS API.</p>
</div>
<div class="section">
<h2><a name="pathnotsupported">Path is not supported: ...</a><span class="sectionMark">§ 7</span></h2>
<p>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:</p>
<p>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:</p>
<pre><code>//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) {});
</code></pre>
<p>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.</p>
<p>If you want to <b>exclude</b> 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:</p>
<pre><code>//Inside the build profile
{
paths: {
'dependency': 'empty:'
}
}
</code></pre>
</div>