0

"Module name has not been loaded yet for context: _. Use require([])"

I am porting a very large and very complex Cordova/PhoneGap application to Windows RT (the OS that runs apps on Windows 8 and the Microsoft Surface). I am in the process of getting our app running on the platform and I keep running into this error. The problem is that our application is so big I have little to no hope of tracing what file is actually causing this error. Adding to my confusion is the fact that this error does not get thrown on Android, iOS or Google Chrome.

I am aware that the RequireJS documentation shows how to solve this error (http://requirejs.org/docs/errors.html#notloaded), but this is a matter of figuring out where to fix this.

Has anyone else found a good way to trace requireJS errors to a specific JavaScript file?

user2428759
  • 221
  • 3
  • 10

1 Answers1

0

When I was facing this problem my issue was that the function inside of define did not have require as the first argument, e.g:

define(["text!templates/mytemplate.html"], function(Template, require) {
    var someModule = require('path/to/module');
    return someModule.doSomething(Template);
});

If that is your problem then perhaps some grep calls might do the trick. Something roughly like:

grep ',[ ]\?require' *.js

There are different ways of achieving the same error so your mileage may vary.

Community
  • 1
  • 1
Andy Novocin
  • 454
  • 3
  • 14