Iron Router:找不到路由定义

Iron Router: No route definitions found

我正在开发一个基本的 meteorjs 应用程序并使用 iron 路由器进行仅客户端路由。我设置了我的路线、出版物和模式,但我无法将 iron router 连接到 运行。在我启动我的应用程序后,它总是显示 "No route definitions found"。我的 router.js 在 /lib 中。改变它的位置根本不起作用。我没有任何控制台日志。感谢任何帮助。

我的router.js:

Router.route('/', {
  name: 'main',
  layoutTemplate: 'mainLay',
  waitOn: function() {
    return Meteor.subscribe('posts');
 },
  action: function() {
    this.render('allPosts');
}
 });

 Router.route('/create-post', {
  name: 'createPost',
  layoutTemplate: 'mainLay',
  action: function() {
    if (Meteor.userId()) {
      this.render('createPost');
    }
    else {
    Router.go('/');
   }
  }
 });

Router.route('/post/:postId', {
 name: 'post',
 layoutTemplate: 'mainLay',
 waitOn: function() {
  return [
    Meteor.subscribe('comments', this.params.postId),
    Meteor.subscribe('post', this.params.postId)
  ];
},
action: function() {
  var postId = this.params.postId;
  this.render('postDetail');
}
});

在我的 .meteor/packages 中有条目:

iron:router

如果您不清楚应用程序结构,这可能会有所帮助: https://guide.meteor.com/structure.html#example-app-structure

找不到 iron-router 的模板:

The router.js is not known by the client entrypoint: /client/main.js

client/
  main.js                      # client entry point, imports all client code

在您当前的情况下:

inside the main.js check if you add:

import '/lib/router.js';