2014-11-22 96 views
1

我是Meteor.js的新手,目前正在研究"leaderboard"示例应用程序。插入一行代码后:“退出代码8”示例流星应用程序

Template.leaderboard.player = function(){ 
    return "Some other text" 
} 

我在应用程序的接口接收到的错误:“你的应用程序崩溃下面是最新的日志”

世界,你好

/home/tomas/.meteor/packages/meteor-tool/.1.0.35.hgbesu++os.linux.x86_32+web.browser+web.cordova/meteor-tool-os.linux.x86_32/dev_bundle/lib/node_modules/fibers/future.js:173 
         throw(ex); 
          ^
ReferenceError: Template is not defined 
    at app/leaderboard.js:13:1 
    at app/leaderboard.js:17:3 
    at /home/tomas/leaderboard/.meteor/local/build/programs/server/boot.js:168:10 
    at Array.forEach (native) 
    at Function._.each._.forEach (/home/tomas/.meteor/packages/meteor-tool/.1.0.35.hgbesu++os.linux.x86_32+web.browser+web.cordova/meteor-tool-os.linux.x86_32/dev_bundle/lib/node_modules/underscore/underscore.js:79:11) 
    at /home/tomas/leaderboard/.meteor/local/build/programs/server/boot.js:82:5 
=> Exited with code: 8 
=> Your application is crashing. Waiting for file change." 

我重新保存该文件,进入终端和停止服务器并重新启动它,并接受这一点:

=> Exited with code: 8 
I20141122-11:01:32.695(-5)? Hello world  
W20141122-11:01:32.697(-5)? (STDERR) 
W20141122-11:01:32.699(-5)? (STDERR) /home/tomas/.meteor/packages/meteor-tool/.1.0.35.hgbesu++os.linux.x86_32+web.browser+web.cordova/meteor-tool-os.linux.x86_32/dev_bundle/lib/node_modules/fibers/future.js:173 
W20141122-11:01:32.701(-5)? (STDERR)      throw(ex); 
W20141122-11:01:32.702(-5)? (STDERR)       ^
W20141122-11:01:32.708(-5)? (STDERR) ReferenceError: Template is not defined 
W20141122-11:01:32.709(-5)? (STDERR)  at app/leaderboard.js:13:1 
W20141122-11:01:32.710(-5)? (STDERR)  at app/leaderboard.js:17:3 
W20141122-11:01:32.710(-5)? (STDERR)  at /home/tomas/leaderboard/.meteor/local/build/programs/server/boot.js:168:10 
W20141122-11:01:32.711(-5)? (STDERR)  at Array.forEach (native) 
W20141122-11:01:32.712(-5)? (STDERR)  at Function._.each._.forEach (/home/tomas/.meteor/packages/meteor-tool/.1.0.35.hgbesu++os.linux.x86_32+web.browser+web.cordova/meteor-tool-os.linux.x86_32/dev_bundle/lib/node_modules/underscore/underscore.js:79:11) 
W20141122-11:01:32.712(-5)? (STDERR)  at /home/tomas/leaderboard/.meteor/local/build/programs/server/boot.js:82:5 
=> Exited with code: 8 
=> Your application is crashing. Waiting for file change. 

我的研究表明,'Exited with code: 8'是错误通常与尝试更改数据库相关联。我对流星非常陌生,我很欣赏输入。

+0

首先不推荐使用'Template.templateName.helpername = function'语法。使用帮助程序块来创建helpers.ie。 'Template.leaderboard.helpers({球员:..})'。尝试使用'流星重置'命令重置应用程序。 – Rajanand02 2014-11-22 16:39:30

回答

1

确保您在if(Meteor.isClient){}块内添加了Template帮助程序代码。如果你在公共区域添加编码,它也会尝试运行服务器端的代码,而服务器端显然不可用Template

if (Meteor.isClient) { 
    Template.leaderboard.helpers({ 
    players: function() { 
     return "Some other text" 
    } 
}); 
0

在我的情况下,错误代码是相同的,即8,但堆栈跟踪是不同的。这是我的堆栈跟踪。

W20150821-20:23:59.161(5.5)? (STDERR) Error: A method named '/players/insert' is already defined 
W20150821-20:23:59.161(5.5)? (STDERR)  at packages/ddp/livedata_server.js:1461:1 
W20150821-20:23:59.161(5.5)? (STDERR)  at Function._.each._.forEach (packages/underscore/underscore.js:113:1) 
W20150821-20:23:59.161(5.5)? (STDERR)  at [object Object]._.extend.methods (packages/ddp/livedata_server.js:1459:1) 
W20150821-20:23:59.161(5.5)? (STDERR)  at [object Object].Mongo.Collection._defineMutationMethods (packages/mongo/collection.js:904:1) 
W20150821-20:23:59.161(5.5)? (STDERR)  at new Mongo.Collection (packages/mongo/collection.js:209:1) 
W20150821-20:23:59.162(5.5)? (STDERR)  at app/leadboard.js:45:15 

我正在做一些事情。然后我做了我的文件备份并保存在同一个文件夹中。由于以下声明如下

CollectionName = new Mongo.Collection('collection-name') 

在整个项目中出现两次。这就是我得到这个错误的原因。我删除了我的备份文件,并将结果整理出来。希望它能帮助未来的人。

0

我同样收到相同的错误!

我的代码

PlayersList = new Mongo.Collection('players'); 
我的两个客户端文档和服务器文档中

行。

看起来这个错误是由于在正确的位置重复或没有收集声明而发生的。