Professor_Membrane
Professor_Membrane

Reputation: 63

Iron Router, Meteor app crashes when router.js is placed in /lib

WINDOWS 7 64BIT

METEOR V 1.2.1

IRON:ROUTER V 1.0.11

I just started learning Meteor and I'm stuck trying to get iron router working properly, currently I have my router.js file in the client folder, which is working fine, but if I place it in the /lib folder the app crashes.

ReferenceError: router is not defined
at lib/router.js:1:1

Upvotes: 0

Views: 86

Answers (2)

Professor_Membrane
Professor_Membrane

Reputation: 63

The fix that worked for me was to remove Iron Router, and the router.js file. Reinstall it, then create a new router.js file. Very possible that as Leonardy Kristianto suggested, the file was somehow corrupt. I've seen this problem several times on here, with no definitive answer, but it seems the overall consensus is to reinstall.

Make sure you have:

  1. The current version of Meteor
  2. The current version of Iron Router
  3. A newly created router.js file

Upvotes: 0

Leonardy Kristianto
Leonardy Kristianto

Reputation: 104

Provided that you have successfully added the iron-router package: from the error thrown by the console, it's possible that you mistyped Router as router.

An excerpt from iron-router repository:

// Create some routes in a client/server JavaScript file
Router.route('/', function () {
    this.render('MyTemplate');
});

Upvotes: 1

Related Questions