Iron router: Error: Couldn't find a template named "/" or "". Are you sure you defined it? - meteor

I have trouble setting up a simple iron:router example: (docs, sample app)
meteor create testapp
cd testapp
home.html:
<template name="Home">
<h1>Welcome</h1>
home
</template>
router.js:
Router.route('/', function () {
this.render('Home'); // Also tried 'home'
});
Starting the server:
meteor
Then I get (client side):
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?88aac5d3c26b7576ac55bb3afc5324f465757709:1853:25)
...
What am I doing wrong ?
Note: I get the exact same error if I clone the example application (basic.html and basic.js).
meteor list
autopublish 1.0.1 Publish the entire database to all clients
insecure 1.0.1 Allow all database writes by default
iron:router 0.9.4 Routing specifically designed for Meteor
meteor-platform 1.1.2 Include a standard set of Meteor packages in your app
Also:
meteor --version
Meteor 0.9.4 <- Why all standard packages and meteor platform are > 1.0 and this is 0.9.4 ?

Currently, there are two versions of iron:router.
iron:router#0.9.4 is the one added by default when you type meteor add iron:router, this version is the latest in the "legacy" branch of iron:router that came up more than one year ago, it's the one that everyone is probably still using, although they should definitely update to...
iron:router#1.0.0-preX with X = 4 as of 20/10/2014, which is a complete rewrite of the package intended to be backward compatible, but introducing a new, nicer and polished API. This version will likely be set as default when meteor hits 1.0.0 later this year. The problem is that github page of iron:router shows this particular branch (1.0.0-pre4) along with examples that people believe are usable with 0.9.4.
This means that you are most likely using the wrong version of iron router, remove it with meteor remove iron:router and meteor add iron:router#1.0.0-pre4 instead.
Recommended reading to learn about the latest iron:router syntax :
http://eventedmind.github.io/iron-router/
Sometimes the guide is not completely up-to-date with the pre-release version, if you want to keep up with the latest stuff take a look at github issues.

Related

Errors while updating Meteor version

I am trying to update my meteor project from 1.8.2 to the latest version. To do this, I have run meteor update outside of a meteor project and got this message:
The latest version of Meteor, 2.3.6, is already installed on this computer. Run 'meteor update' inside of a particular project directory to update that project to Meteor 2.3.6
After that, I go into my project directory and run the same meteor update and receive this message:
=> Errors while initializing project:
While selecting package versions:
error: No version of standard-minifier-js satisfies all constraints: #2.6.1, #=2.5.0, #~2.6.1
Constraints on package "standard-minifier-js":
* standard-minifier-js#2.6.1 <- top level
* standard-minifier-js#=2.5.0 <- top level
* standard-minifier-js#~2.6.1 <- top level
No version of babel-compiler satisfies all constraints: #=7.4.0, #~7.7.0
Constraints on package "babel-compiler":
* babel-compiler#=7.4.0 <- top level
* babel-compiler#~7.7.0 <- top level
* babel-compiler#7.7.0 <- ecmascript 0.15.3 <- 416serg:simple-text-rotator 0.0.1
I'm not too clear on what the above error message means so if someone could explain that would be amazing. Even better if you've got any tips or ideas to solve this. Please let me know if you need any additional information!
As requested in comment, .meteor/packages:
# Meteor packages used by this project, one per line.
# Check this file (and the other files in this directory) into your repository.
#
# 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand.
# autopublish
# insecure
accounts-ui#1.3.1
accounts-password#1.5.1
# documentation for iron router talks about a higher version.
# but, example todos and others use 0.9.4 which uses routes without a slash(/),
# and actual url is specified on path property.
iron:router#=0.9.4
jquery
underscore#1.0.10
email#1.2.3
alanning:roles
meteor-base#1.4.0
mobile-experience#1.0.5
mongo#1.7.0
blaze-html-templates
session#1.2.0
tracker#1.2.0
logging#1.1.20
reload#1.3.0
random#1.1.0
ejson#1.1.0
spacebars
check#1.3.1
matb33:collection-hooks
# for stripe mrgalaxy:stripe
mrgalaxy:stripe
momentjs:moment
themeteorchef:jquery-validation
http#1.4.2
# for theme
less
twbs:bootstrap#3.3.5
fortawesome:fontawesome
reactive-var#1.0.11
summernote:summernote
dsyko:meteor-node-csv
#force-ssl
peppelg:bootstrap-3-modal
416serg:simple-text-rotator
risul:bootstrap-colorpicker
tomi:upload-jquery
dangrossman:bootstrap-daterangepicker
hellotech:moment-timezone
agnito:simptip
#abhiaiyer:meteor-twilio
jercle:livestamp
#msavin:mongol
tmeasday:publish-counts
kadira:blaze-layout
standard-minifier-css#1.5.4
standard-minifier-js#2.6.1
shell-server#0.4.0
dynamic-import#0.5.1
tomi:upload-server#1.3.4_3
tsega:mentions
montiapm:agent
mizzao:autocomplete
huaming:js-xlsx
edgee:slingshot
mizzao:user-status
I also have a file .meteor/packages~ (not sure what this is or if it's relevant):
# Meteor packages used by this project, one per line.
# Check this file (and the other files in this directory) into your repository.
#
# 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand.
# autopublish
# insecure
accounts-ui
accounts-password
# documentation for iron router talks about a higher version.
# but, example todos and others use 0.9.4 which uses routes without a slash(/),
# and actual url is specified on path property.
iron:router#=0.9.4
jquery
underscore
email
alanning:roles
standard-minifiers
meteor-base
mobile-experience
mongo
blaze-html-templates
session
tracker
logging
reload
random
ejson
spacebars
check
# for stripe mrgalaxy:stripe
mrgalaxy:stripe
momentjs:moment
themeteorchef:jquery-validation
http
# for theme
less
twbs:bootstrap#3.3.5
fortawesome:fontawesome
reactive-var
summernote:summernote
dsyko:meteor-node-csv
#force-ssl
peppelg:bootstrap-3-modal
416serg:simple-text-rotator
risul:bootstrap-colorpicker
tomi:upload-server
tomi:upload-jquery
dangrossman:bootstrap-daterangepicker
It seems that you have all of these in your top-level, i.e., .meteor/packages:
babel-compiler#=7.4.0
babel-compiler#~7.7.0
standard-minifier-js#2.6.1
standard-minifier-js#=2.5.0
standard-minifier-js#~2.6.1
which express version constraints on the named packages. There are no versions for these two packages that satisfy all given constraints. But it seems pretty safe to say that you can reduce this to:
babel-compiler#~7.7.0
standard-minifier-js#2.6.1
but if
babel-compiler#~7.7.0
standard-minifier-js#~2.6.1
works, that would probably save you some trouble down the road, so I would try that first.
If you want to learn more about these constraint expressions, they are Semantic Versioning constraints, i.e., the same as used by npm: https://docs.npmjs.com/cli/v7/configuring-npm/package-json#dependencies.

Meteor app can't find routes

New to meteor. Just cloned a git repo, and upon launching the app, I get a router.js:347 There is no route for the path: / error.
This is my route for root in imports/startup/client/routes.js
FlowRouter.route('/', {
name: 'Home',
action() {
BlazeLayout.render('app_body', {tabs: 'tabs', inbox: 'inbox', upload: 'upload', invite: 'invite'});
console.log('root loaded');
},
});
Here is the list of packages
accounts-facebook 1.0.10 Login service for Facebook accounts
accounts-password 1.2.14* Password support for accounts
alanning:roles 1.2.15 Authorization package for Meteor
aldeed:collection2 2.9.1 Automatic validation of insert and update operations on the client and server.
aldeed:simple-schema 1.5.3 A simple schema validation object with reactivity. Used by collection2 and autoform.
arillo:flow-router-helpers 0.5.2 Template helpers for flow-router
blaze-html-templates 1.0.4 Compile HTML templates into reactive UI with Meteor Blaze
check 1.2.3 Check whether a value matches a pattern
dburles:collection-helpers 1.0.4 Transform your collections with helpers that you define
ecmascript 0.5.7* Compiler plugin that supports ES2015+ in all .js files
email 1.1.16* Send email messages
es5-shim 4.6.13* Shims and polyfills to improve ECMAScript 5 support
hpx7:youtube-iframe-player 0.4.15 Control YouTube's embedded player using Meteor
http 1.2.8* Make HTTP calls to remote servers
jazeee:spiderable-longer-timeout 1.2.13 Extended spiderable package: SSL, caching, longer timeout, no stdin issues, publish flag
jchristman:tagsinput-autocomplete-edited 1.1.0+ A combination of the mizzao:autocomplete library and a tagsinput-like functionality
jquery 1.11.9 Manipulate the DOM using CSS selectors
kadira:blaze-layout 2.3.0 Layout Manager for Blaze (works well with FlowRouter)
kadira:flow-router 2.12.1 Carefully Designed Client Side Router for Meteor
keepnox:perfect-scrollbar 0.6.8 Perfect-scrollbar packaged for meteor
manuel:reactivearray 1.0.5 Reactive Array for Meteor
matb33:collection-hooks 0.8.3* Extends Mongo.Collection with before/after hooks for insert/update/remove/find/findOne
meteor-base 1.0.4 Packages that every Meteor app needs
meteorhacks:aggregate 1.3.0 Proper MongoDB aggregations support for Meteor
mobile-experience 1.0.4 Packages for a great mobile user experience
momentjs:moment 2.14.4 Moment.js (official): parse, validate, manipulate, and display dates - official Meteor packaging
mongo 1.1.10* Adaptor for using MongoDB and Minimongo over DDP
reactive-dict 1.1.8 Reactive dictionary
reactive-var 1.0.10 Reactive variable
sacha:spin 2.3.1 Simple spinner package for Meteor
saucecode:timezoned-synced-cron 1.2.11 Fork of original w/ timezone support. Define and run scheduled jobs across multiple servers.
session 1.1.6 Session variable
spiderable 1.0.13 Makes the application crawlable to web spiders
standard-minifier-css 1.1.8* Standard css minifier used with Meteor apps by default.
standard-minifier-js 1.1.8* Standard javascript minifiers used with Meteor apps by default.
tomwasd:flow-router-seo 0.0.3 A simple way to set the title and meta tags for sites using flow router
tracker 1.1.0 Dependency tracker to allow reactive callbacks
twbs:bootstrap 3.3.6 The most popular front-end framework for developing responsive, mobile first projects on the web.
What is it that is causing the app not to find the routes file? I have looked through the following posts for some guidance, but have found none.
Meteor Routing Error : There is no route for the path: /
https://github.com/kadirahq/flow-router/issues/608
https://github.com/kadirahq/flow-router/issues/185
http://coderchronicles.org/2016/04/08/getting-started-with-meteor-1-3-react-and-flowrouter/
Any help solving the problem would be appreciated. I feel like I'm missing something simple.
-S
**project file structure
imports/
startup/
client/
index.js
routes.js
server/
fixtures.js
index.js
api/
server/
publications.js
ui/
components/
layouts/
pages/
client/
main.js
head.js
main.js
server/
main.js
fixtures.js
server-global.js
Are you importing the routes file into your app's main container?
For example, if you have a /client/main.js file that gets loaded from client side at startup, then it should include the import reference to routes file as follows:
import '/imports/startup/client';
Or, import '/imports/startup/client/routes.js';
Put your route file in 'imports/starup/lib' (lib - for example). In fast-render package recommended use 'lib', if you wanna use it. If no - 'client';
Then make sure you imported your route file in 'root/client/main.js';
Please, read this part of docs: https://guide.meteor.com/structure.html#javascript-structure
It is very helpful article.
UPD:
Please, remove duplicate files in your client/main.js
When, in client/main.js
import '/imports/startup/client';
In your imports/startup/client/index.js
import './routes.js';
And now it will work.
Dont forget, you must import all views you wanna use in your route.
Problem fixed. Instead of launching with meteor run, need to launch with meteor --settings settings.json --production

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.
The reason you have this issue is there is a discrepancy between the iron-router#1.0.0-pre-x (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:router#1.0.0-pre3
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

CoffeeScript Packages Not Working with Meteor 0.9.0.1

After upgrading to 0.9.0.1 it would seem that CoffeeScript packages have two problems:
The exports from package.js don't seem to be exported.
The source files don't seem to be compiled.
package.js:
Package.describe({
summary: "sunburn"
});
Package.on_use(function (api, where) {
api.add_files(['lib/sunburn.coffee'], 'server');
api.export && api.export('Stinger', 'server');
});
Package.on_test(function (api) {
});
sunburn.coffee:
Stinger = -> "stinger here"
This is a local package. Both 'meteor add sunburn' and 'meteor remove sunburn' work fine. If sunburn.coffee is modified the server restarts. However, 'Stinger' is undefined when used from the server-side code. Somewhat more interestingly, if sunburn.coffee is modified to include syntax errors, the server will happily restart and no error will be reported. This is what leads me to believe that the CoffeeScript files aren't even being compiled. Or, at least, not being fully "wired up".
Code similar to this worked in the pre 0.9 version.
One last note: if the sunburn.coffee is changed to be a normal js file, 'Stinger' rewritten as normal javascript, and the file path updated in package.js, the above works fine.
Thanks :-)
You need to specify that your package actually depends on coffeescript to make the compilation happen :
api.use("coffeescript","client");
Previously, only having your app depending on build plugins (less, coffeescript, etc...) was OK but apparently now you have to specify that you use them inside packages as well.
Unrelated, but you should also specify a version in your Package.describe, and testing for the existence of api.export is unrelevant because I hope nobody is using Meteor < 0.6.5 anymore.

Meteor 0.8.0, Iron Router and Discover Meteor

Meteor 0.8.0 is out with the new Blaze rendering, which is great... for the future.
At the present I can't run my Iron Router powered app: updated -> ran meteor -> white browser screen. I guess I'll roll back to 0.7.2. but that gives me a fuzzy feeling. Its like have a new computer with no internet connection. Is there any fix for these changes? At least for Iron Router?
Note Comment (although it was in the title):
I am learning meteor using the Discover Meteor book, it's a great book written by same author of Iron Router; I love it. However, if meteor changed that much am I wasting my time?
Update
#iAmME's solution works great! I solved it another way that also fixed iron-router-progress by modifying the smartpackage. Just wanted to post it if it helps anyone:
{
"packages": {
"blaze-layout": {},
"iron-router":
{
"git": "https://github.com/EventedMind/iron-router.git",
"branch": "blaze-integration"
},
"iron-router-progress":
{
"git": "https://github.com/Multiply/iron-router-progress.git",
"branch": "blaze-integration"
}
}
}
Just faced the same issue,
Did the following and works fine
It occurs mostly because of the iron-router package and few other packages which are using spark as dependency and first re-install the iron-router like below
meteor remove iron-router
rm -rf packages/iron-router
mrt update
mrt add iron-router
Just re-installing the iron-router will update you to the new version and also it installs blaze-Layout automatically with the iron-router(which is the new templating system).
After updating iron-router,Even now if you are getting spark is not defined error,check which package is using spark and update those packages too.
You have to update your iron-router package. Check out the Iron Router github page https://github.com/EventedMind/iron-router for information on what's new in their 0.7.0 release. It works for Meteor 0.8.0.

Resources