Iron Router not working with Meteor 1.2?

Anyone else experiencing issues with Iron Router? I just ran meteor update and now I can’t load a template.

Also getting this in the Chrome console:

Exception in callback of async function: ReferenceError: EJSON is not defined
    at MiddlewareStack.concat (http://localhost:3000/packages/iron_middleware-stack.js?ff70621b6c5f6a406edc60600c4b76126dae21d6:303:25)
    at RouteController._runRoute (http://localhost:3000/packages/iron_router.js?dd5fa02859b6335661b94134bd9903be8eecf44d:542:17)
    at Function.Route.dispatch (http://localhost:3000/packages/iron_router.js?dd5fa02859b6335661b94134bd9903be8eecf44d:856:18)
    at route (http://localhost:3000/packages/iron_router.js?dd5fa02859b6335661b94134bd9903be8eecf44d:713:11)
    at boundNext (http://localhost:3000/packages/iron_middleware-stack.js?ff70621b6c5f6a406edc60600c4b76126dae21d6:425:31)
    at Meteor.bindEnvironment (http://localhost:3000/packages/meteor.js?637cc835a2ee4a2302a010c9a4c97b906db5f41c:1007:22)
    at dispatch (http://localhost:3000/packages/iron_middleware-stack.js?ff70621b6c5f6a406edc60600c4b76126dae21d6:449:3)
    at http://localhost:3000/packages/iron_router.js?dd5fa02859b6335661b94134bd9903be8eecf44d:393:13
    at Tracker.Computation._compute (http://localhost:3000/packages/tracker.js?16c53d4f91467c6a41bbb860bf6c48f871710022:357:36)
    at new Tracker.Computation (http://localhost:3000/packages/tracker.js?16c53d4f91467c6a41bbb860bf6c48f871710022:245:10)

Cheers.

2 Likes

And as usual, as I type that out I found a solution on Github.

In case anyone else comes across the same problem, just add ejson with:

meteor add ejson

Then it’s fixed.

May as well keep this here for reference.

Cheers.

10 Likes

Does this mean ejson is not included in the standard set of packages anymore?

Any chance you created this with Iron CLI?

I had the exact same issue when I tried to do that this morning, and found the same fix.

Seems maybe iron-cli needs updating?

No idea. Looks like it could be the case though.

Have a read of this: https://quip.com/RXFlAk9Rc2xI

They have restructured the packages within the meteor repository now, and not all of them are inside one big wrapper package as they were before. Iron Router will likely have to update it’s dependencies to use EJSON again.

Following @korus90 's recommendation will make EJSON available everywhere in your application, which is a workaround. The correct solution would be for IronRouter and any other package which requires it, update their api.use dependencies.

1 Like

It looks like Iron Router .use’s ejson so it should be ok.

It might be your version of Iron Router. 1.0.9 is the latest.

It has .use’d ejson for a long time: https://github.com/iron-meteor/iron-router/commit/74a7ad44d7514dd117cdc480802ad5d6956b9a5b though so it is confusing.

Did you try a clean build?(meteor reset)

Completely clean, a new project. I just thought I’d update meteor while I was at it!

Found it https://github.com/iron-meteor/iron-middleware-stack/blob/master/package.js Doesn’t .use ejson.

I would encourage you to submit a bug report there!

Thanks! Just came across same problem!

I threw up a PR regarding this: https://github.com/iron-meteor/iron-middleware-stack/pull/7

1 Like

Same here. I’m new to Meteor and using Iron Router, so none of the tutorials were working. Thanks for posting this here folks so I didn’t waste more time staring at a blank screen!

Thanks for sharing the workaround @korus90!

So until the iron router package is updated to include this ejson change, we use the workaround you suggested. After iron:router makes the fix, we would do a meteor reset, and manually re-add all the packages in our project? So I would have to keep a list of all packages that I’m using, or is there a way meteor knows which packages were included before the reset?

Just want to make sure I’m understanding how meteor reset works properly.

I think meteor reset just resets the database. Your best bet will be to simply update iron:router when the update is out and then do meteor remove ejson to get rid of it (since you shouldn’t need it anymore).

1 Like

And thanks for that! I was at work when I came across the issue and got involved in something so forgot to make my own PR.

I’ve also opened a github issue on the main repo: https://github.com/iron-meteor/iron-router/issues/1443 in the hopes it will get some attention.

If anyone else can get in touch with the contributors to iron router please do so.

1 Like

Thanks! I was pulling my hair out!

-Ben

1 Like

Thanks a ton, after installed ejson, worked like a charm.

1 Like

Thank you!!! even my issue with iron router was solved immediately

Great post.

1 Like

Thank you so much! After running CLI command meteor add ejson it is working.

1 Like