所以我创建了一个默认的 meteor 应用程序。
运行良好。
现在,我在启动函数中添加一个简单的插入。
现在它给了我异常(exception)。

这是我的app.js代码:

Book = new Meteor.Collection("book");

if (Meteor.isClient) {
  Template.hello.greeting = function () {
    return "Welcome to app_01.";
  };

  Template.hello.events({
    'click input' : function () {
      // template data, if any, is available in 'this'
      if (typeof console !== 'undefined')
        console.log("You pressed the button");
    }
  });
}

if (Meteor.isServer) {
  Meteor.startup(function () {
    if (Book.find().count() === 0) {
      var names = ["Ada Lovelace",
                   "Grace Hopper",
                   "Marie Curie",
                   "Carl Friedrich Gauss",
                   "Nikola Tesla",
                   "Claude Shannon"];
      for (var i = 0; i < names.length; i++)
        Book.insert({name: names[i], score: Math.floor(Math.random()*10)*5});
    }
  });
}

这是我得到的异常(exception):
No dependency info in bundle. Filesystem monitoring disabled.
Errors prevented startup:
Exception while bundling application:
Error: ENOTEMPTY, directory not empty 'C:\Users\Office\Workspace\Code\Meteor\app_01\.meteor\local\build\server'
    at Object.fs.rmdirSync (fs.js:456:18)
    at Object.module.exports.rm_recursive (C:\Program Files (x86)\Meteor\app\lib\files.js:256:10)
    at C:\Program Files (x86)\Meteor\app\lib\files.js:254:15
    at Array.forEach (native)
    at Function._.each._.forEach (C:\Program Files (x86)\Meteor\lib\node_modules\underscore\underscore.js:79:11)
    at Object.module.exports.rm_recursive (C:\Program Files (x86)\Meteor\app\lib\files.js:252:9)
    at _.extend.write_to_directory (C:\Program Files (x86)\Meteor\app\lib\bundler.js:493:11)
    at Object.exports.bundle (C:\Program Files (x86)\Meteor\app\lib\bundler.js:685:12)
    at exports.run.restart_server (C:\Program Files (x86)\Meteor\app\meteor\run.js:615:26)
    at C:\Program Files (x86)\Meteor\app\meteor\run.js:726:9

Please fix the problem and restart.

控制台根本没有提供任何有用的信息。

更多信息:
我正在使用Windows版本的 meteor 0.5.4
我的代码同时具有制表符和空格作为缩进(应该有问题吗?)

使我更加困惑:
如果我运行排行榜示例,它将运行完美。

当我使用修改后的启动代码运行默认项目时,出现异常。 >。<

更多信息:
当服务器崩溃时,mongod服务仍在Windows中运行。用我的无限智慧,我想我会杀死它,也许尝试重新启动它。

现在我得到一个新的错误:
PS C:\Users\Office\Workspace\Code\Meteor\app_01> meteor
[[[[[ C:\Users\Office\Workspace\Code\Meteor\app_01 ]]]]]

Unexpected mongo exit code 100. Restarting.
Unexpected mongo exit code 100. Restarting.
Unexpected mongo exit code 100. Restarting.
Can't start mongod

MongoDB had an unspecified uncaught exception.
Check to make sure that MongoDB is able to write to its database directory.

编辑:现在删除.meteor/local/db内容。我们现在回到ENOTEMPTY错误。

最佳答案

这是因为在 bundle 操作期间目录不会被删除。

因此,在发生这种情况时,请使用ctrl + c停止服务器。

然后删除.meteor\local\db目录以及.meteor\local\builds目录的内容,然后使用meteor命令再次运行服务器。

这不是一种理想的方法,但是它可行。

10-07 19:28
查看更多