我正在研究一个流星项目,这是我第一次使用Meteor。
一切正常,直到我决定做一个" git init"进入我正在工作的目录,然后是" git checkout -b gh-pages"。所以我可以在这里向S.O.发布一个回购和现场演示。因为我完全有一个完全不同的问题。
在摆弄过去很容易的事情(创建gh页面)之后,这个过程对我来说不再适用,不确定GitHub是否改变了创建页面的过程,但由于某种原因它不能为我工作,即使按照这些说明操作后:https://help.github.com/articles/creating-project-pages-manually/
创建另一个分支并尝试将代码推送到gh-pages后,我突然开始出现这些错误。
对不起,这很长:
=> Started proxy.
=> Started MongoDB.
W20141230-20:19:22.649(-5)? (STDERR)
W20141230-20:19:22.735(-5)? (STDERR) /Users/MARS/.meteor/packages/meteor-tool/.1.0.38.z83ibe++os.osx.x86_64+web.browser+web.cordova/meteor-tool-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:173
W20141230-20:19:22.735(-5)? (STDERR) throw(ex);
W20141230-20:19:22.735(-5)? (STDERR) ^
W20141230-20:19:22.735(-5)? (STDERR) Error: A method named '/players/insert' is already defined
W20141230-20:19:22.736(-5)? (STDERR) at packages/ddp/livedata_server.js:1444:1
W20141230-20:19:22.736(-5)? (STDERR) at Function._.each._.forEach (packages/underscore/underscore.js:113:1)
W20141230-20:19:22.736(-5)? (STDERR) at [object Object]._.extend.methods (packages/ddp/livedata_server.js:1442:1)
W20141230-20:19:22.736(-5)? (STDERR) at [object Object].Mongo.Collection._defineMutationMethods (packages/mongo/collection.js:886:1)
W20141230-20:19:22.736(-5)? (STDERR) at new Mongo.Collection (packages/mongo/collection.js:208:1)
W20141230-20:19:22.737(-5)? (STDERR) at app/leaderboard.js:1:50
W20141230-20:19:22.737(-5)? (STDERR) at app/leaderboard.js:80:3
W20141230-20:19:22.737(-5)? (STDERR) at /Users/MARS/Desktop/Sandbox/meteor/leaderboard/.meteor/local/build/programs/server/boot.js:175:10
W20141230-20:19:22.737(-5)? (STDERR) at Array.forEach (native)
W20141230-20:19:22.737(-5)? (STDERR) at Function._.each._.forEach (/Users/MARS/.meteor/packages/meteor-tool/.1.0.38.z83ibe++os.osx.x86_64+web.browser+web.cordova/meteor-tool-os.osx.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
=> Exited with code: 8
在以" =>结尾之前,它做了三次。您的应用程序崩溃了。正在等待文件更改。"
以前有没有人遇到过这种情况,或者有人可以解释为什么会发生这种情况?
这是我到目前为止唯一的代码:
PlayersList = new Mongo.Collection('players');
if(Meteor.isClient){
Template.leaderboard.helpers({
'player' : function(){
return PlayersList.find( {}, {sort: {score: -1, name: 1} });
},
'count' : function() {
return PlayersList.find().count();
},
'selectedClass' : function() {
var playerId = this._id;
var selectedPlayer = Session.get('selectedPlayer');
if(playerId === selectedPlayer) {
return "selected";
}
},
'showSelectedPlayer' : function() {
var selectedPlayer = Session.get('selectedPlayer');
return PlayersList.findOne(selectedPlayer);
}
});
Template.leaderboard.events({
'click .player' : function() {
var playerId = this._id;
Session.set('selectedPlayer', playerId);
},
'click .increment' : function() {
var selectedPlayer = Session.get('selectedPlayer');
PlayersList.update(selectedPlayer, {$inc: {score: 5} });
},
'click .decrement' : function() {
var selectedPlayer = Session.get('selectedPlayer');
PlayersList.update(selectedPlayer, {$inc: {score: -5} });
},
'click .remove' : function() {
var selectedPlayer = Session.get('selectedPlayer');
alert('Are you sure you want to delete this fool?');
PlayersList.remove(selectedPlayer);
}
});
Template.addPlayerForm.events({
'submit form' : function(event) {
event.preventDefault();
var playerNameVar = event.target.playerName.value;
var playerScoreVar = event.target.playerScore.value;
PlayersList.insert({
name: playerNameVar,
score: playerScoreVar
});
var formAddPlayer = document.getElementById('formAddPlayer');
formAddPlayer.reset();
}
});
}
if(Meteor.isServer){
}
感谢。
答案 0 :(得分:1)
之前我遇到过这样的问题。为我修复的是刚刚运行git clean -dfx
我真的没有看到你的代码有任何错误,应该抛出该错误。可能只是git很奇怪。
答案 1 :(得分:0)
错误A method named '/xxx/insert' is already defined
有点模糊,但这意味着您在服务器上运行了两次这样的代码。
PlayersList = new Mongo.Collection('players');
鉴于您在文件顶部有一次,您应该在目录的其他位置查找它。
我不确定git具体做了什么,但错误是由于集合被定义了两次,因此在目录中的某处必须存在重复的代码块。