I'm new to requireJS, and I'm trying to figure out why I can't get normal errors.
I'm using this, right after the requirejs file is loaded, but before any modules are loaded:
requirejs.onError = function (err) {
console.log(err.requireType);
if (err.requireType === 'timeout') {
console.log('modules: ' + err.requireModules);
}
throw err;
};
But I'm still getting the completley vague error:
Error: script error
http://requirejs.org/docs/errors.html#scripterror @ http://localhost/wampir/lib/require.js:8
"scripterror"
Is there a way to make this give me the actual error and line number?
I've seen this question but I've tried several answers from there, and they don't change anything...
RequireJS is, in web-terms, an old technology now (some might say ancient), but it is still in wide use and there have been a number of questions about RequireJS and DataTables recently.
To fix the problem, you must update your JavaScript define methods within RequireJS, according to following documentation: https://requirejs.org/docs/api.html#define.
RequireJS is probably the most popular implementation of AMD. One major difference from CommonJS is that AMD specifies that modules are loaded asynchronously - that means modules are loaded in parallel, as opposed to blocking the execution by waiting for a load to finish.
Is RequireJS synchronous? So, RequireJS doesn't support it. From your use case it seems that you don't need synchronous RequireJS, you need to return result asynchronously. AMD pattern allows to define dependencies and load them asynchronously, but module's factory function must return result synchronously.
Remove the "timeout" check. It's keeping you from seeing the modules you're having a problem with unless the problem happens to be a timeout.
requirejs.onError = function (err) {
console.log(err.requireType);
console.log('modules: ' + err.requireModules);
throw err;
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With