I just started learning Require.js
the file system is similar:

This is my index.html
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> <script type="text/javascript" src="lib/require/require.min.js" data-main="lib/main"></script> </head> <body> <span id="content"></span> </body> </html>
Now I know that the 1st file loaded in the DOM is require.js, after which it loads lib / main.js
Now main.js is located
require(['jquery'],function($){ //this works since both **main.js** and **jquery.js** are in same folder $("#content").html("jquery am loaded"); });
Now here is the problem, if I save jquery.js in the same folder as in main.js, the code works fine, but if I changed the path to jquery / jquery.js and changed main. js as
require(['jquery/jquery'],function($){ //this thing shows 'Uncaught TypeError: undefined is not a function' $("#content").html("jquery am loaded"); });
I realized that the problem is that it does not load jquery.js if it is inside any other folder, the other one is main.js , but why, please, shed some light and how this can be achieved.
source share