Errors when collections are defined in /collections?


We are following the pattern of yogiben:meteor-starter, and defining our collections in the /collections directory. However, sometimes we are getting CollectionName is not defined in client code. Where should collections be defined so that they are always available in client/server code?

Two examples of when we are getting the CollectionName is not defined error are:

  • When calling the CollectionName from within /lib or /both

  • When calling the CollectionName from within /collections/hooks/


Meteor begins parsing your code from the deepest directory (except for lib) therefore if you define a collection higher in the folder structure where some other piece of code that is buried deeper references it, that reference will have been yet undefined.


Thanks. We have since started using explicit import statements in our files related to collections.