1

when I start meteor like this:

meteor --production

I get a blank page where my app should be and the following error shows up in my browser console:

No such function: navClassName

However if I start meteor normally like this:

meteor

My app runs without problem.

What could be the problem? Do meteor template helpers need to be loaded differently during production?

Relevant files: client/navigation/navigation.html:

<template name="navigation">
    <ul class="nav navbar-nav">
        <li class="{{navClassName 'home'}}">
            <a href="{{pathFor 'home'}}">home</a>
        </li>
        <li class="{{navClassName 'blog'}}">
            <a href="{{pathFor 'blog'}}">Blog</a>
        </li>
    </ul>
</template>

client/navigation/navigation.js:

Template.navigation.helpers({
  'navClassName': function (route) {
    if (Router.current()) {
      return Router.current().route.options.navbarSelected.search(route) != -1 ? "active" : "";
    }
  }
});
icedTea
  • 495
  • 2
  • 7
  • 12

1 Answers1

0

Move navigation.js to the client/lib directory, or at least the Template.navigation.helpers part and fix/remove any other JavaScript that is causing errors.

I wish I could elaborate more, but this issue seems to be related to the file load order. Files in the lib directory are loaded first and moving the helpers there solved the problem for me.

A typical file structure can be found in the documentation. See the comments in the Example File Structure to learn about some of the special behaviors.

While this may work for you, finer control over dependencies can most easily be achieved through packages, as explained in this other answer from SO. This is specially necessary for code that should be available to both client and server.

Community
  • 1
  • 1
mper
  • 191
  • 8