Help! I\'m trying to use jquery in my node.js app, but I keep getting an error when I try to use \'$\', saying \"$ is not defined\"... but I defined it at the top! Here\'s what
//make sure $ is available in the global scope
var $;
function doSomething(){
var deferred = $.Deferred();
}
require("jsdom").env("", function(err, window) {
if (err) {
console.error(err);
return;
}
// assign it
$ = require("jquery")(window);
// you have to call it in here because you are in a callback
doSomething();
});