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

Prob­lem :

Requir­ing a file using sim­pli­fied com­monJS syn­tax for example,

var jQuery = require('jQuery');

throws the fol­low­ing error

Uncaught Error: Module name has not been loaded yet for context: _. Use require([]) 
http://requirejs.org/docs/errors.html#notloaded

Solu­tion :

You need to con­vert your requires to the nor­mal call­back syn­tax. Read this arti­cle for Dif­fer­ence between nor­mal call­back vs sim­pli­fied commonJS

var jQuery = 'jQuery';

// ES5
require([jQuery], function(result){
    jQuery = result;
});

// ES6
require([jQuery], result => jQuery = result;);

You may also like...