Sunday, August 31, 2014

Meteor Creating Package Errors & how to fix them (Template Not Defined & Cannot Set Property)

Meteor in August 2014 moved from meteorite packaging towards supporting a built in package management as part of the core framework. As of this writing, Meteor is at v0.9.0.1.

I was in the process of creating a package for meteor and encountered a couple of errors. It was not easy to find answers so I thought i would post them here:

Error 1: Uncaught ReferenceError: Template is not defined
              Exception from Deps recompute function: Error: No such template:

Adding the following in package.js solved the error for me:

package.js:
    api.use(['templating'],'client');


Error 2: Uncaught TypeError: Cannot set property 'rendered' of undefined ez-menu.js:2
Exception from Deps recompute function: Error: No such template:

This error was tricky to find and i did a lot of google-fu to figure out what was going wrong. Since i solved the first error, i knew the Template was defined now. But, why would the rendered function not be available. Why was the template coming back as undefined???

The silliness was the order of operations in package.js.. 
  • Make sure you add the HTML file before any CSS or JS files
  1.  api.addFiles('easy-side-menu.html', 'client');
  2.  api.addFiles(['easy-side-menu.js', 'slideout-menu.css'], 'client');