所以我创建了一个默认的流星应用程序。它运行良好。现在我在启动函数中添加一个简单的插入。它现在给了我例外。
这是我的 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.
控制台根本没有给我任何有用的信息。
更多信息:我正在使用 windows 版本的流星 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 错误。