javascript - requireJS Optimization : "Uncaught TypeError: undefined is not a function" - Stack Overflow

I am using requireJS for the first time. I got it working fine then came to optimize the files to minif

I am using requireJS for the first time. I got it working fine then came to optimize the files to minify and concatenate and now I get the error "Uncaught TypeError: undefined is not a function" the error is on line 8175 of front-built.js. I have left the file unminifed for this question to make it easier to identify the problem.

My main JS file before optimization looks like this (works fine): .js

And after optimization (throws the error on line 8175): .js

Hope someone is more familier with requireJS than me and can fix this issue. Is may be the way I'm including my JS file before optimization. I'm really not sure.

I am using requireJS for the first time. I got it working fine then came to optimize the files to minify and concatenate and now I get the error "Uncaught TypeError: undefined is not a function" the error is on line 8175 of front-built.js. I have left the file unminifed for this question to make it easier to identify the problem.

My main JS file before optimization looks like this (works fine): http://thebeer.co/js/front.js

And after optimization (throws the error on line 8175): http://thebeer.co/js/front-built.js

Hope someone is more familier with requireJS than me and can fix this issue. Is may be the way I'm including my JS file before optimization. I'm really not sure.

Share Improve this question asked Mar 2, 2011 at 16:09 wilsonpagewilsonpage 17.6k23 gold badges105 silver badges150 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

I see the problem there:

define('globals',["jquery"],(function($){
  var   siteWrap = $('#siteWrap'),
        membersTab = $('#membersTab'),
        mID = siteWrap.attr('mID');

  if(window.location.host == "dev.thebeer.co"){
    var staticURL = "http://static.thebeer.co";  
  }else{
    var staticURL = "https://static.meshmesh.us"; 
  }

  // ... SNIP SNIP ....

})());

You're not passing jQuery to the anonymous function, therefore $ is undefined inside the function. That last line should be like this:

})(jQuery));

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745051720a4608429.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信