3thanZ
3thanZ

Reputation: 45

Error when using iron:router with Meteor 0.9.3.1

I am experimenting with Meteor and iron:router. I git cloned the examples from https://github.com/EventedMind/iron-router.git. I then cd-ed into samples/basic, and ran meteor update and meteor. My meteor version is 0.9.3.1

When I navigated to the website an error is displayed in console and the page is empty. The error is as below:

Exception from Tracker recompute function: Error: Couldn't find a template named "/" or "". Are you sure you defined it?
at null._render (http://localhost:3000/packages/iron_dynamic-template.js?32038885cb1dad7957291ffebfffcb7f8cd57d20:239:17)
at doRender (http://localhost:3000/packages/blaze.js?7b7ff7ee2ccdccd85a1ad0d8dc9d96193e29e8b0:1853:25)
at http://localhost:3000/packages/blaze.js?7b7ff7ee2ccdccd85a1ad0d8dc9d96193e29e8b0:1795:16
at Object.Blaze._withCurrentView (http://localhost:3000/packages/blaze.js?7b7ff7ee2ccdccd85a1ad0d8dc9d96193e29e8b0:2029:12)
at viewAutorun (http://localhost:3000/packages/blaze.js?7b7ff7ee2ccdccd85a1ad0d8dc9d96193e29e8b0:1794:18)
at Tracker.Computation._compute (http://localhost:3000/packages/tracker.js?192a05cc46b867dadbe8bf90dd961f6f8fd1574f:288:36)
at new Tracker.Computation (http://localhost:3000/packages/tracker.js?192a05cc46b867dadbe8bf90dd961f6f8fd1574f:206:10)
at Object.Tracker.autorun (http://localhost:3000/packages/tracker.js?192a05cc46b867dadbe8bf90dd961f6f8fd1574f:476:11)
at Blaze.View.autorun (http://localhost:3000/packages/blaze.js?7b7ff7ee2ccdccd85a1ad0d8dc9d96193e29e8b0:1793:19)
at http://localhost:3000/packages/blaze.js?7b7ff7ee2ccdccd85a1ad0d8dc9d96193e29e8b0:1847:10 debug.js:41

Can someone kindly advise what I am doing incorrectly?

Thanks in advance.

Upvotes: 2

Views: 682

Answers (1)

Tarang
Tarang

Reputation: 75975

The reason you have this issue is there is a discrepancy between the [email protected] (like a Beta for 1.0) and the currently in use 0.9.x version of iron router.

The old notation for defining a route for http://localhost:3000/route, for the template route would be as follows:

Router.route("route", { path : '/' });

However in the new version, which is currently on github on devel (which I presume the examples are based on is as follows):

Router.route("/", function() {
    this.render("route");
});

The problem is using the notation on the bottom would lead to the error Couldn't find a template named "/" since the first param of the Route.route is now a path instead of a template.

The way to fix this is to either use the pre-release version of iron router (the version string can be found in the package.js file on github):

meteor remove iron:router
meteor add iron:[email protected]

Or to use the old notation by looking at an example bundled with a release on github instead of the devel branch like this one: https://github.com/EventedMind/iron-router/tree/v0.9.2-rc0

Upvotes: 6

Related Questions