I want to use jQuery with require.js and I got some problem I need to use jQuery inside module1 & 2
The require.js is working well but not able to load jquery
This is the index.html
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Basic example of requireJS integration</title>
</head>
<body>
<div id="container">
<p>Check console and js files</p>
</div>
<script data-main="js/main" src="js/vendor/require.js"></script>
</body>
</html>
this is the main.js
// Load modules and use them
requirejs.config({
path: {
'jquery': '../js/vendor/jquery-3.1.1.min',
}
});
require(['module1', 'module2'], function (module1, module2) {
debugger;
console.log(module2.testMod1() + " " + module2.testMod2());
});
This is module1
define([], function () {
return {
doSomething: function () {
return 'something';
}
};
});
This is module2
define(['module1', jquery], function (module1, $) {
return {
testMod1: function () {
debugger;
console.log("jquery obj" + $);
return module1.doSomething();
},
testMod2: function () {
return "something 2"
}
};
});
I read this but not able to make it work...what am I doing wrong here ? Correct way to implement jQuery with require.js
update: still after changing like Michael Sacket answer, having same issue this is my project structure
Now the error is:
require.js:168 Uncaught Error: Script error for "jquery", needed by: module2
http://requirejs.org/docs/errors.html#scripterror
at makeError (require.js:168)
at HTMLScriptElement.onScriptError (require.js:1735)
