为什么我会收到ENOTEMPTY错误?

时间:2013-02-14 13:45:39

标签: windows meteor

所以我创建了一个默认的流星应用程序。 它的运行很棒。 现在我在启动函数中添加一个简单的插入。 它现在给我例外。

这是我的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});
    }
  });
}

这是我得到的例外:

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.

控制台根本没有给我任何有用的信息。

更多信息: 我正在使用流星版0.5.4的Windows版本 我的代码有标签和空格作为缩进(应该是一个问题?)


增加了我的困惑: 如果我运行排行榜示例,它会完美运行。

当我使用修改后的启动代码运行默认项目时,我得到了异常。 &GT;。&LT;


更多信息: 当服务器崩溃时,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错误。

3 个答案:

答案 0 :(得分:3)

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

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

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

不是理想的方式,但它有效。

答案 1 :(得分:2)

刚刚在我的Mac和我的Windows机器上测试过,它对我来说很好。 (将您的代码复制并粘贴到app.js中,在其他任何地方都没有改变任何内容,因为我知道这就是您所做的事情。)

有两种方法可以继续:

  1. 您尝试meteor reset警告:这会清空您在此应用中拥有的所有数据库,但我认为目前没有任何重要内容可供使用?
  2. 您使用meteor create appname删除该应用并制作一个新应用,并将上面的源代码复制到app.js。
  3. 我认为投入太多时间和精力是不值得的,因为它不是一个接近生产阶段的应用程序。但是,如果创建新应用程序会导致同样的问题,那么它会变得有趣=)

    编辑:刚搜索过,发现:https://github.com/TomWij/meteor/issues/18 向下滚动到答案;显然它可能是你的防病毒扫描程序阻止Meteor重建它。那可能吗? 另外,你是否从cmd.exe以外的任何其他东西启动Meteor?我只是在GitHub上阅读了这个问题,当使用除cmd.exe以外的任何东西(例如GitHub Bash Shell)时,事情似乎相当粗糙。

答案 2 :(得分:1)

我的拉取请求进入后,应该解决此问题:

https://github.com/TomWij/meteor/pull/56