title: Require.js : Uncaught TypeError: Object function ... has no method
body: <p>I'm getting an Uncaught TypeError when i refresh the page, my <strong>js/app/main.js</strong> file can't call the method update() on <strong>js/app/utilities/resize.js</strong>.</p>
  
  <h2><strong>Error output</strong></h2>
  
  <blockquote>
    <p>Uncaught TypeError: Object function U(n){return n&amp;&amp;typeof n=="object"&amp;&amp;!me(n)&amp;&amp;ne.call(n,"<strong>wrapped</strong>")?W(n)} has no method 'update'</p>
  </blockquote>
  
  <p>I haven't managed to isolate/replicate the issue into a simplified working example unfortunately. But you can click on the js files within the folder tree below for gists.</p>
  
  <ul>
  <li><em>index.html</em></li>
  <li><strong>js /</strong> 
  <ul>
  <li><em><a href="https://gist.github.com/camoconnell/5755383" rel="nofollow">app.js</a></em></li>
  <li><strong>lib /</strong>
  <ul>
  <li><em>require.js</li>
  <li>jquery.js</li>
  <li>... etc</em></li>
  </ul></li>
  <li><strong>app /</strong>
  <ul>
  <li><em><a href="https://gist.github.com/camoconnell/5755455" rel="nofollow">main.js</a></em> - <em>Uncaught TypeError @line 566</em></li>
  <li><strong>utilities /</strong>
  <ul>
  <li><em><a href="https://gist.github.com/camoconnell/5755437" rel="nofollow">resize.js</a></em></li>
  <li><em>scroll.js</em></li>
  <li><em>... etc</em></li>
  </ul></li>
  </ul></li>
  </ul></li>
  </ul>
  
  <h2>app.js</h2>
  
  <pre><code>require.config({
  
      urlArgs: "bust=" + (new Date()).getTime(),
  
      baseUrl: WP.THEME_URL+"/js",
  
      paths: {
          app     : "app"
          , jquery  : "lib/jquery-2.0.2.min"
          , ...
          , resize    : "app/utilities/resize" 
          , ...
      }
  });
  
  require(["app/main"],function(){});
  </code></pre>
  
  <p>The method <strong>update()</strong> is being called on <em>resize.js</em> from <em>main.js</em>;</p>
  
  <h2><strong>main.js</strong></h2>
  
  <blockquote>
    <p>define([ 'require' , 'jquery' , ... ,'resize' ], function( require , $ , ... , resize ) {   </p>
    
    <p>...</p>
    
    <p>function setup() {</p>
  
  <pre><code> resize.update(); // Uncaught TypeError happens here
  </code></pre>
    
    <p>} </p>
    
    <p>$doc.ready( setup );</p>
  </blockquote>
  
  <h2><strong>resize.js</strong></h2>
  
  <pre><code>define([],function () {   
  
      var resizeItems = [],
          update = function () {
  
              for (i = 0; i &lt; resizeItems.length; i++){
                  var item = resizeItems[i];
                  item.callback( App.screen.width , App.screen.height );
              }
          };
  
      return {
          update  : update,
          add     : function( item ) { resizeItems.push( item ); }
      }
  });
  </code></pre>
  
  <p>Thanks in advance</p>
  
  <hr>
  
  <p><strong>Edit</strong> :  It seems it was a dependancy issue. Adding "resize" to require on app.js has resolved it;</p>
  
  <pre><code>require(["resize","app/main"],function(){});
  </code></pre>
  
  <p>I thought suppling "resize" to define() in main.js would have ensured correct deps;</p>
  
  <pre><code>define([ 'require' , 'jquery' , ... ,'resize' ], function( require , $ , ... , resize )...
  </code></pre>