This is a super quick and simple post... but maybe it'll save someone time down the line. I sure won't make the mistake again. I spent more time than I would like to admit figuring out this issue. There are a lot of posts sprinkled around about different causes of the error, none of which were the cause of my error.
Given the following RequireJS config:
require.config({
"baseUrl":"\/path\/to\/dir\/",
"paths":{
"jQuery":"jquery.js"
}
});
I was trying to do the following:
require([jQuery], function ($) {
console.log($);
});
That gave me the dreaded "jQuery not defined" error!
Solution
Add quotes around "jQuery"!
require(["jQuery"], function ($) {
console.log($);
});
Without the quotes jQuery was being treated as a Javascript variable instead of a string. So when it was looking for the jQuery dependency it did not exist. "jQuery" on the other hand does.